cancel
Showing results for 
Search instead for 
Did you mean: 

I2c problem

spa23
Associate III
Posted on September 06, 2011 at 20:51

Hi

I have a small problem that I hope you can help me with. My problem I that the I2C communication stops after some time.

I have 2 IRQ, one I2C and one timer 3 update with highest priority, TIM3 interrupt with 20kHz.

The I2C works fine if I disable the TIM3 IRQ.

I am controlling a digital Potentiometer with the I2C.sending address and 2 data byte.

When the I2C works, the event comes as:

I2C_EVENT_MASTER_MODE_SELECT

I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED

I2C_EVENT_MASTER_BYTE_TRANSMITTING

I2C_EVENT_MASTER_BYTE_TRANSMITTING

I2C_EVENT_MASTER_BYTE_TRANSMITTED

but if I enable Timer 3, The I2C stops after: (after some times) 

I2C_EVENT_MASTER_MODE_SELECT

if I look at the signal with a scoop the address is never transmitted to the slave.

Hope you can help me with an idea.. thanks

Ihave attached the code if it will help solving the problem. 

#i2c
5 REPLIES 5
ColdWeather
Senior
Posted on September 07, 2011 at 10:03

Hello!

> The I2C works fine if I disable the TIM3 IRQ.

The STM32F I2C state machine is very ''sensitive'' to the timings. Being interrupted in the ''inconvenient'' point it fails. Reading the manual (RM0008) regarding I2C and AN2824  carefully you'll see that it is recommended either to assign to the I2C the highest interrupt priority or to ''protect'' certain I2C event processing steps by disabled interrupts.

emalund
Associate III
Posted on September 07, 2011 at 15:23

also read the errata.  ST tried to be nice and 'improve' on the I²C and failed miserably.  Double buiffering I²C is a mistake

Erik

ColdWeather
Senior
Posted on September 08, 2011 at 11:44

> Double buiffering I²C is a mistake

ABSOLUTELY.

spa23
Associate III
Posted on September 08, 2011 at 13:10

Thanks for you reply.

I have tried to disable the TIM3 IRQ but with out any luck, so now I have deicide to use a chip with SPI instead.
emalund
Associate III
Posted on September 08, 2011 at 16:04

A radical, but effective, solution 🙂

Erik