I need an I2C Slave sample

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

I need an I2C Slave sample

跳至解决方案
3,460 次查看
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.

标签 (1)
1 解答
1,986 次查看
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 项奖励
回复
3 回复数
1,986 次查看
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,986 次查看
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 项奖励
回复
1,987 次查看
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 项奖励
回复