Open gamelaster opened 3 years ago
@gamelaster Thanks, we will fix this issue soon
Thank you 😊
Also, don't use i2c_set_freq function, use I2C_ClockSet instead, since i2c_set_freq
don't set all clocks.
@gamelaster Please provide your sample code to reproduce this issue. Cause there are different levels of API in SDK. Thanks
@YafeiJin the i2c_set_freq
API doesn't work wrongly, it correctly sets the registers, but not all of them (and also, it doesn't check for current hclk freq). It doesn't use GLB_Set_I2C_CLK
, so it's not possible to get higher I2C frequencies.
Example:
i2c_set_freq(0, 100); // 100 KHz
(As you can see, the clock frequency is barely 1000 Hz)
But when using I2C_ClockSet:
I2C_ClockSet(0, 100000)
(Now, there is everything OK)
Please try again by switching params
@YafeiJin Ah yes, I'm blind 😁 thank you
Should this be closed? Should this be documented (or enforced) to take a better argument than "int" ?
Related to this post on BBS, I found the reason why this happens. Here when NACK happens, it calls
i2c_callback
which disables all interrupts and generally the I2C. Anyway, at that time, the I2C BUSY flag is still true, and there is not possible to immediately make another I2C transmission.When we don't disable I2C on NACK, the flow is following: I2C_TXF_INT > I2C_NAK_INT > I2C_NAK_INT > I2C_END_INT (and now is BUSY flag false). So my solution is after NACK happen, don't disable interrupts or I2C, just set status and wait for END interrupt. Then everything works like charm.