flexio_i2c_s32k118 sample code bug?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

flexio_i2c_s32k118 sample code bug?

920 次查看
jimmylee0407
Contributor I

I use S32SDK_S32K1xx_RTM_3.0.0, flexio_i2c_s32k118 sample code, and change the baud rate from 100000 to 400000. The i2c output is correct as expected (see "Correct_400k_-O1" below). 

However, if I change the optimization level from -O1 to -O0(None), the i2c output will repeat the slave address. As you can see on "Incorrect_400k_-O0(None)" below, the second byte is 0x4A instead of 0x00.

I've attached the project file. I can understand normally optimization causes abnormal, but in this case none optimization causes abnormal. Just wondering if this is a bug?

Figure 1: Correct_400k_-O1

ok1.png

Figure 2: Incorrect_400k_-O0(None)

ng1.png

1 回复

789 次查看
cristianzamfire
NXP Employee
NXP Employee

Hello,

I suspect this is a Tx underflow. When Flexio starts sending the address, an interrupt is generated to request more data for transmission. If the CPU does not provide the data before the address is fully sent, the same value will be sent again instead of the first data byte. Compiling with optimization level O0 makes the code slower, so this could explain why it did not work, while O1 worked.

Please check the return value of the FLEXIO_I2C_DRV_MasterSendDataBlocking function, the driver should detect this error and report it.

To fix this issue, you could use the driver in DMA mode, or lower the baud rate.

Best regards,

Cristian