AnsweredAssumed Answered

KW41Z router_eligible_device_freertos problem I2C communication during CoAP callback

Question asked by DIEGO COMIN on Sep 7, 2018
Latest reply on Oct 23, 2018 by Alexandru-lilian Natarau

Hi all,

 

The objective of my project is to communicate to my Raspberry PI through I2C when I make use of a CoAP petition from the user. I used "frdmkw41z_wireless_examples_thread_router_eligible_device_freertos" as project base and I configured the KW41Z as I2C slave (from the driver_examples_i2c_polling_transfer) because RP is my I2C master:

When there is an I2C transfer the next callback is called (a 32 byte buffer to transfer and a 1 byte variable to receive):

 

 

To perform an I2C communication between the CoAP user KW41Z and the Raspberry-Pi I perform the next rule: 

  • If I only want to send data from the user to the RP I make use of a CoAP POST + DATA, where, I put a pin high (input interrupt of the RP) in order to make know to the master i2c (RP) that my KW41Z has a data to send. When the RP receive the interrupt it starts to read the 32 byte data buffer and verifies the data payload to perform an operation. Then, the CoAP sends the ACK to the user. It works OK.

 

 

  • However, when I want to receive data from the RP to the User there are some problems. I make use of a CoAP GET, where the chart flow I follow is the following: I put the pin high to make an interrupt to the RP, RP reads the 32 bytes buffer, it verifies the payload that tells him that KW41Z need to know a sensor data, RP writes the sensor data byte to the KW41Z and the User receives an ACK + DATA.

The graphic flow it should show is:

 

But in my case, when the user receives the ACK + DATA that works OK, the Thread program enters to the CoAP callback another time. So the RP receives another PIN interrupt and perform the same operation as before, the real graphic flow is the following in my case:

What could be the problem? It is related to the I2C interrupt callback? What is the best way to perform an I2C operation during a CoAP callback in the router_eligible_device_freertos? 

 

I perform the I2C operation in the RP though the SMBus library.

 

It is a really important issue we need to fix in our company in order to solve our IoT project.

 

I really apreciate some help,

 

Diego Comín

Outcomes