Reply
Highlighted
Posts: 7
Registered: ‎12-08-2014

EFM32ZG I2C not working

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

Posts: 14
Registered: ‎11-02-2014

Re: EFM32ZG I2C not working

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...

Posts: 14
Registered: ‎11-02-2014

Re: EFM32ZG I2C not working

[ Edited ]
Posts: 7
Registered: ‎12-08-2014

Re: EFM32ZG I2C not working

I did some more testing, found an error iny my code. Attached are a few waveforms of my communication to ISL29023. Can somebody do a quick check if this waveforms look ok? First waveform is writing to slave device (address 0x88) to register 0x00 value 0x00. Second picture is writing value 0xA0 to this same register. Then we have two waveform, reading from register 0x03 and then from 0x02. This should be lux values from ISL29023.
Posts: 7
Registered: ‎12-08-2014

Re: EFM32ZG I2C not working

I did some additional testing on ISL29023. Attached is picture of reading a register at address 0x03 and here is what I got 

 

Read_DATAMSB_1112.jpg

 

and here is what i got when reading a register at address 0x02

 

Read_DATALSB_1112.jpg

 

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?

Posts: 7
Registered: ‎12-08-2014

Re: EFM32ZG I2C not working

And just another thing - after 2 sequential reads I saw that in the third read I got different picture:

 

Read_DATAMSB_nack.jpg

 

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?

Posts: 7
Registered: ‎12-08-2014

Re: EFM32ZG I2C not working

Hi again,

 

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?

 

thanks