I need an I2C Slave sample

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

I need an I2C Slave sample

ソリューションへジャンプ
4,225件の閲覧回数
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 解決策
2,751件の閲覧回数
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 返答(返信)
2,751件の閲覧回数
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

2,751件の閲覧回数
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 件の賞賛
返信
2,752件の閲覧回数
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 件の賞賛
返信