I need an I2C Slave sample

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

I need an I2C Slave sample

Jump to solution
3,124 Views
shuichiy
Contributor III

Hi, I'm looking for sample codes for I2C on MK22F which works as I2C slave just like EEPROM device.

A external master (maybe PC) sends 1 or 2 bytes register address followed by write data, or a master sends 1 or 2 bytes register address then read data.

 

I have already tested I2C slave interrupt and slave interrupt_transfer samples in the KSDK, but they are not enough cause it seems they need fixed buffer length for slave transfer.

 

Do you have any ideas ?

I'm a new to Kinetis so your any advice will be appreciated.

Labels (1)
1 Solution
1,650 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Shuichi Yokota:

Unfortunately there is no example code for emulating an EEPROM memory in I2C slave mode with KSDK.

About the example projects you found:

- The i2c_interrupt_transfer indeed requires fixed buffer lengths for transmission and reception, since it uses the transactional APIs from the I2C driver. I think this project would not be useful in your case.

- The i2c_interrupt project has fixed buffer lengths just to demonstrate the use of the driver APIs. You can actually take this project to understand the use of the slave mode APIs and construct your application. Then you have to redesign the interrupt handler for the EEPROM use case. In the example project the handler is called I2C_SLAVE_IRQHandler().

Regards!

Jorge Gonzalez

View solution in original post

0 Kudos
3 Replies
1,650 Views
shuichiy
Contributor III

Hi Jorge,


Thanks for your advice.

Finally I have created an emulation of EEPROM memory based on the i2c_interrupt sample. It handles some signals such as a stop condition, and works with memory address.

Regards,

Shuichi

1,650 Views
lucasrangit
Contributor III

Hi shuichiy‌, Can you take a look at my implementation for the simulated EEPROM I2C slave device in https://community.nxp.com/message/842400  . It is based on the same example but I've rewritten the ISR and cannot get multiple byte reads to work. Did you get this working?

0 Kudos
1,651 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Shuichi Yokota:

Unfortunately there is no example code for emulating an EEPROM memory in I2C slave mode with KSDK.

About the example projects you found:

- The i2c_interrupt_transfer indeed requires fixed buffer lengths for transmission and reception, since it uses the transactional APIs from the I2C driver. I think this project would not be useful in your case.

- The i2c_interrupt project has fixed buffer lengths just to demonstrate the use of the driver APIs. You can actually take this project to understand the use of the slave mode APIs and construct your application. Then you have to redesign the interrupt handler for the EEPROM use case. In the example project the handler is called I2C_SLAVE_IRQHandler().

Regards!

Jorge Gonzalez

0 Kudos