4 posts / 0 new
Last post
hrg
Offline
Last seen: 3 years 1 month ago
Guru
Joined: 2014-08-05 13:37
Two I2c connections

Is two I2C conections possible at the same time ? am using I2C eeprom & also an I2C RTC ,both should be working at the same time .so how to configure the GPIO pins in the SDK ?
Also how to initialize and acess both in the SDK ?

JE_Dialog
Offline
Last seen: 3 months 2 weeks ago
Staff
Joined: 2013-12-05 14:02
Hello hrg,  I2C by definition

Hello hrg,  I2C by definition allows mutliple conenctions on the bus. We dont have any examples right now on multiple connections. I will need to check internally .

BR JE_Dialog

hrg
Offline
Last seen: 3 years 1 month ago
Guru
Joined: 2014-08-05 13:37
Please check and acknowledg

Please check and acknowledg about the software usage in the SDK asap .

JE_Dialog
Offline
Last seen: 3 months 2 weeks ago
Staff
Joined: 2013-12-05 14:02
Hello hrg, here is an example

Hello hrg, here is an example of a  temperature sensor (SE95) . It shows how to configure an i2c device; the access of which is determined by its address.  This is the key point : ensuring that the address is sent on the bus to select the right device.

BR JE_Dialog

 

step 1. open the SDK-software:
SDK … \peripheral_examples … DA14580_peripheral_setup.uvproj

step 2. see: periph_setup.h:
change the HARDWARE_CONFIGURATION_INDEX (.) to ‘1’.

/* Test Definition - Select the Configuration that matches your H/W setup
*---------------------------------------------------------

  • (0) SPI FLASH MEMORY WITH UART
  • (1) I2C EEPROM WITH UART
  • (2) QUADRATURE ENCODER WITH BUZZER AND UART
    *---------------------------------------------------------
    */
    // <o> Hardware Configuration <0=> SPI Flash with UART <1=> I2C EEPROM with UART <2=> Quadrature Encoder, Timers & Buzzer with UART
    #define HARDWARE_CONFIGURATION_INDEX (1) // 1 => I2C

step 3.
add new software in: eeprom_test.c (at the beginning of the file)

volatile int16_t temperature;
volatile int ii;

// testing peripheral SE95 temperature sensor
// address = 1001 A2 A1 A0 R/W => 7bitaddress = 0x48 ... 0x48 + 7 = 0x4F

i2c_eeprom_init(0x48, I2C_STANDARD, I2C_7BIT_ADDR, I2C_1BYTE_ADDR);

// reading internal ID-number:
ii = i2c_eeprom_read_byte(0x05); // test reading ID-value = 0xA1

// reading temperature
btrd = i2c_eeprom_read_data(rd_data, 0, 2);

temperature = 256 * rd_data[0] + rd_data[1];
temperature = temperature / 8; // shift 3 bits to right