I have a problem with I2C an debbuging

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

I have a problem with I2C an debbuging

1,036 Views
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.

Labels (1)
Tags (3)
0 Kudos
Reply
4 Replies

761 Views
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 Kudos
Reply

761 Views
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 Kudos
Reply

761 Views
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 Kudos
Reply

761 Views
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 Kudos
Reply