Hi everybody. I'm working several days now on I2C code. I have STK3200 and ambient light sensor ISL29023. I tested code from AN00011, I2C is on location 0 (PA0 and PA1) and I can't make it work. Then I tried another MCU, EFM32ZG108F32 and this time I used LIS3DH accelerometer and sample code for weatherstation. I also tested code from here: https://eewiki.net/pages/viewpage.action?pageId=33882195, both examples but still no success. First I was getting i2cArbitrationLost error, from time to time I got NACK response. I can't make the darn thing to work!! Is there any TESTED code for I2C that acctualy works? I was reading articles in community and I see that a lot of people have problems with I2C. For example when I used NXP LPC1114 I got I2C working in 15 minutes, interrupt driven. This was ofr ISL29023 that I wantet to use with EFM32ZG. But here no game. Any help or sample code that is really tested will be very much appreciated. Also how is it here with I2C addresses - do you have to add read bit to the address or is this handeled in emlib drivers? thanks
The weather station code is working for me.
I have also tried other i2c ICs, and they work fine too. The TI fuel gauge IC bq27510 , a particular difficult chip that requires proper protocol timing worked ok.
I'll upload my example Simplicity Studio project...
I did some additional testing on ISL29023. Attached is picture of reading a register at address 0x03 and here is what I got
and here is what i got when reading a register at address 0x02
Slave address is 0x88 which is seen at the begining. the I see master sends address of register to read from and then is sends slave address with R bit set but then I don't know what is happening. Can someone please check this if this is ok for this sequence?
And just another thing - after 2 sequential reads I saw that in the third read I got different picture:
I think ACK is missing at the end. Am I right? The code for this is based on bq27510 sample code posted above, the only difference is that I'm writing this in Keil. Can this have any influence?
after some tests I saw that I needed to remove this line of code
I2C0->CTRL |= (1 << 2);
and than it started to work. But now I'm facing a new problem. I have a board where I have 2 I2C slaves and one master (EFM32ZG108F32). My code is working fine if only one slave is present but as soon as there are two I'm getting i2cTransferArbLost from i2c_Transfer function. I'm lost and unfortunately I don't have scope with me. Does anybody have any idea why this is happening?