cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG with FreeRTOS

Jack Davidson
Associate
Posted on January 12, 2017 at 12:52

Hi All,

I would like to use BlueNRG as a FreeRTOS task. I use an IBD04A1 board with a Nucleo 401 board.

Everything seems to be good, I copied the bluetooth handling codes into a task configured by CubeMX.

The task initializes the board and the infinite loop contains only

HCI_Process();

User_Process(&axes_data);

Bluetooth is working well (I can connect with an android phone), but no other task can run.

When I put a osDelay(1) inside the loop, the bluetooth cannot works (cannot discover it, and no connection), but other tasks canot run too.

If I call only the  getBlueNRGVersion(&hwVersion, &fwVersion); beginning of the task and there is only an osDelay inside the taskloop, it damages the multitasking system. Maybe some dead lock happened?

I can get any help where can I find the problem.

thank you

Jack.

#bluenrg #freertos
1 REPLY 1
Barry.Richard
Associate III
Posted on January 12, 2017 at 21:40

I'm not familiar with the BlueNRG software, but it sounds like it is running in an infinite loop without ever blocking so starving any lower priority tasks of any processing time, but adding a fixed delay is breaking the real time requirements of the stack.  Normally a blunt but easy way of fixing this would be to run the code that never blocks at priority 0, but in this case it sounds like that might stop the Bluetooth working.  Therefore you will probably have to make the Bluetooth code event driven, so it is able to enter the Blocked state when it has nothing to do, but still be kept at a high priority.

Does the Bluetooth interface rely on interrupts?  If so so then the task could possible Enter the Blocked state while it is waiting for an interrupt, then immediately start running again when the interrupt arrives.  See the example code on the following page for an example of how this can be done:  

http://www.freertos.org/vTaskNotifyGiveFromISR.html