FRDM-KW41z thread low power end device freertos

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

FRDM-KW41z thread low power end device freertos

1,223 Views
xanthurum
Contributor II

In an IOT project with the frdm-kw41z I need to implement several sensors. These sensors make use of I2C or UART or an analogue input.
As this device is an end device I have chosen to use Thread as the network mesh.

As this is an end device it’s obvious to make use of an RTOS. While one sensor is waiting on data from its serial interface another sensor can start its task.
As it is not possible to select a separate middleware Thread driver. I started the project from an example: “frdmkw41z_wireless_examples_thread_low_power_end_device_freertos”.

In the example the “APP_Handler” calls in a loop the “NWKU_MsgHandler”.  So far the principle is clear. But when I want to implement my own “taskMsgQueu_t” types I get lost in the complexity of this example. Especially because this code is barely documented.

pastedImage_3.png

What is the best way to implement my own RTOS task events and a static events table and what parameters?


Am I supposed to add my events in the “aStaticEventsTable” in the file “event_manager_globals.c”?

pastedImage_2.png

How do I best set the priority of my tasks without interfering with, for ex. the TMR_Task, Mac_Task, THR_Task…?

What task is managing the time-period the end device to go in sleep mode or to start measuring?

As the SDK provides a serial manager I opt to use that one to implement UART and I2C communication. Though the serial manager lacks the parameter READ or WRITE for I2C communication.

pastedImage_4.png
Do I have to add the I or 0 myself ad the end of the slave address?

Labels (1)
0 Kudos
3 Replies

855 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

As you mention , the serial manager adds complexity to the example,  by any chance, is there another reason why you want to use it? 

For what you are trying to do, I believe that the best and easier way to achieve it would be by using a interruption that enables an event. 

You can also use as an example the ADC usage and just adapt it for the i2c. 

Regards, 

Estephania 

0 Kudos

855 Views
xanthurum
Contributor II

Dear Estephania 

I choose to use the serial manager because that code has already its own events within the system.

The use of a RTOS, FreeRTOS is especially to avoid the use of a plethora of interrupts.

The problem stays the priority scheme of the FreeRTOS tasks and how to add the events that triggers their use.

It would be nice to have a bird's-eye view or some kind of flowchart of the biggest blocks of code within the example. 

Dependency's and priority's would be more clear then.

Best regards

Pascal

0 Kudos

855 Views
diegocomin
Contributor IV

Hello estephania_martinez‌,

I followed this link because I am experiencing some slave i2c callback problems when I try to communicate my KW41Z (i2c slave) with my Raspberry Pi (i2c master) due to the interrupts interfering the clean FreeRTOS operation, link: KW41Z router_eligible_device_freertos problem I2C communication during CoAP callback 

It would be interesting to have a good documentation related how to use our custom FreeRTOS tasks in the "router_eligible_device_freertos" with the convenient priorities, our task queues in order not to interfere the TMR_Task, MAC_Task, THR_Task, etc. 

Also it would be nice to have some view of the "router_eligible_device_freertos" tasks flowchart.

In this way, What would be the best way to implement a real time machine of states with tasks in the "router_eligible_device_freertos" program, where the transitions between states are performed when different CoAP callbacks occur.

Regards,

Diego Comin

0 Kudos