2008-02-12 10:54 PM
I2C speed
2011-05-17 03:23 AM
Hi,
When I read coefficient of HP03 with a I2C speed of 100khz, there is no problem but when I choose 400khz, the program stop when I send the restart. The have already check the sensor on LPC2134 and he run correctly at this speed. Please found the program in attachement piece. Have I missed a config in STM32F103RB? What is the solution to run at 400khz? In a another program, I use RTC and when an interrupt occur, the rtc increment his date, but if I read a measure of sensor or I send a buffer to drive LCD (i2c to), the condition (While(!I2C_Event ...)) failed at all time. Can I replace this condition with another who don't failed? Thanks2011-05-17 03:23 AM
Dear Boubou,
You can refer to this Thread discussion : you can find similar points to your configuration. Hope this clarifies the situation you are facing. STOne-322011-05-17 03:23 AM
Dear STOne-32,
thanks, but I have read this thread before. At 400kHz, frequency is 400kHz. I have check my hardware, and the pull-up resistance on i2c bus are correct for a 400khz speed. I think I2CCheckEvent don't see correctly the ack of the slave. If I debug with breakpoint, the condition of I2CCheckEvent failed! For the moment, I run at 100khz but I would run at 400kHz Thanks2011-05-17 03:23 AM
Hi boubou,
I don't know if this helps, but I have found when rapidly changing from master TX mode to master RX mode on the I2C interface, sometimes the interrupt flag is set, but the flags which cause the interrupt are cleared when changing modes - it results in a spurious interrupt. To illustrate - I use a PCA9555 I2C i/o device. I need to send an address and then receive data from the device. To do this, I send data to the device and then issue a I2C_GenerateSTOP(I2C2, ENABLE) function call. This is done in the I2C interrupt. Immediately afterwards I issue a START command (I2C_GenerateSTART(I2C2, ENABLE)). I have found that at high speed this can cause issues - A simple solution is to add a small delay between issuing the STOP command and the new START command (at the point where the mode changes from master TX to Master RX. I don't know if that's your problem, but it's worth a try. I found the delay only needs to be around 5-10us.