I have a problem with I2C an debbuging

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

I have a problem with I2C an debbuging

1,060 次查看
saul_2510
Contributor I

When i run my application it doesn't works, but when i debug it step by step it works!

It's a problem with an I2C reading, i'm using the FRDM-KL03Z.

标签 (1)
标记 (3)
0 项奖励
回复
4 回复数

785 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Customer,

  Joe is correct, if you want to receive your I2C code, you need to use while to wait the receive flag(I2C_S_IICIF_MASK) is set after you read the data.

  I attached the KL03 i2c driver for your reference.

  If you still have question, just let me know!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

785 次查看
saul_2510
Contributor I

Hi Jingjing,

I'm doing it in that way, i'm waiting for the flags till it sets! But still failling, the problem is with the repeated start condition, when i use it, it sends the last byte that i sent in the bus, instead the address that im trying to send, it works only debugging step by step!

0 项奖励
回复

785 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

Thank you for your more details!

Actually, we have a lot of I2C sample code for FRDM-KL03 in our SDK_2.0_FRDM-KL03Z, please download it from this link:

kex.freescale.com/en/welcome

Choose FRDM-KL03 in the board, then generate the KSDK2.0 package.

After you download it, you can find the I2C sample code in folder :SDK_2.0_FRDM-KL03Z\boards\frdmkl03z\driver_examples\i2c

Please refer to this code and test it on your side.

If you still have question after refer to the KSDK2.0 I2C sample code, please let me know!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

785 次查看
JHinkle
Senior Contributor I

When it works stepping it via a debugger but fails with no debugger - I'd look for a race condition that the code is not addressing.

Hardware events (like I2C) take some time to complete.  If your code does not take these delays into account, it can "race" in front of the hardware and produce faults.

Make sure your code is waiting of I2C flags before your move to your next step.

Hope that helps.

Joe

0 项奖励
回复