I2C1 as Master on FRDM-K22F

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

I2C1 as Master on FRDM-K22F

850 Views
sandeepajesh
Contributor III

Hi Experts,

 

I have a FRDM K22F board (MK22FN512VLH12) and  connected one light sensor to it.

 

I have connected I2C sensor on I2C1 module of the board.[Pin55 as I2C1_SCL & Pin 56 as I2C1_SDA] and configured it as I2C Master.

 

Slave address for my device is 0x23. I have modified freertos_i2c_frdmk22f code to test it.

 

When i am trying to write on this slave address, I am getting error [Error code:- 0x451:- kStatus_I2C_Addr_Nak. NAK received during the address probe]

 

Can you please help here,where i did mistake and how to proceed.

 

Regards

Sandeep S

Original Attachment has been moved to: freertos_i2c.c.zip

Labels (1)
Tags (2)
0 Kudos
5 Replies

524 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Sandeep sharma,

   This is not the code problem, your slave give NACK, it seems your slave didn't give response, you can check the I2C wave in the I2C bus.

  Whether the I2C wave meet your slave device demand, please also check your slave datasheet.

Wish it helps you!

 


Have a great day,
Kerry

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

0 Kudos

524 Views
sandeepajesh
Contributor III

Hi Kerry,

Thanks for the Response.

Yes Kerry, I placed a oscilloscope in between and tried to see waves. After configuring the I2C1 as Master at clock 400000Hz ,i think we should be able to see clock on the line.But I can't see anything on the scope, even on SCL line.

That's why i was suspecting problem from the FRDM-K22F I2C side. Anything else that i can try here?

Regards

Sandeep S

0 Kudos

524 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi sandeep sharma,

    I copy your file to the KSDK2.1-FRDM-K22 board, and use the logic analyzer to check the I2C wave in PTC10(i2c_scl), and PTC11(I2C_SDA), I get this wave:

pastedImage_3.png

9 bit: 7bit address(0x23) +1bit(W) +1bit(NACK).

Your slave really didn't give ACK.

Please add external 10Kpull up in the i2c wave.

Actually, because you just use the I2C master mode, then you don't need to add the slave code.

Wish it helps you!

If you still have question, please let me know!


Have a great day,
Kerry

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

0 Kudos

524 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi sandeep sharma,

  Ok, I will check your code, and reply you later.


Have a great day,
Kerry

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

0 Kudos

524 Views
sandeepajesh
Contributor III

Thanks Kerry,

Will wait for your help.

0 Kudos