2020-08-07 03:00 PM
Hello! I am trying to control a set of leds through bluetooth. In the main function ,after the main task I call the function that manage the leds and into this function there is HAL_Delay that has to receive its argument from bluetooth. The problem starts when I try to find the board using ST BLE Sensor app :
1) It takes a remarkable time to appear on the devices' list. When I connect successfuly to board then appear the second issue:
2) when I send the data (write characteristic) it also delays. How could I solve these delays?
2020-08-14 07:18 AM
My wording may be no clear. As there is no operating system running on the STM32WB (it is a basic bare metal implementation), the only way to interrupt a code execution is an interrupt.
The sequencer (a big while loop) was introduced to cope with this lack of real time OS. You can use the wait_event functionality to let some execution time to another task while waiting for an event.
Now you can understand that the complete BLE event process is not performed only under interrupt. One part is done in a task registered to the sequencer with a certain priority level.
2020-08-14 03:07 PM
Thanks very much for the datailed answer. I'm going to try the wait_event functionality.
2020-08-17 02:10 PM
hello! @Remi QUINTIN I tried to use UTIL_SEQ_WaitEvt to let a time for my task and wait for the event (reception of bluetooth data) but when UTIL_SEQ_WaitEvt is set the system enters the low power mode, that is, my cicle just gets stuck. I am doing something wrong?
And could you please explain a bit more about raising the priority of the background task?
2020-08-18 07:18 AM
Did you get the interrupt?
2020-08-19 05:41 AM
Entering the low power should not prevent the reception of any interrupt or event.
There should be something wrong with the UTIL_SEQ_WaitEvt .
Could you explain/expose the part of code you modified?
2020-08-19 07:49 AM
here is the loop
and here the recepetion of the data
2020-08-19 10:07 AM
It looks good!
You can play with the priority of the task using the UTIL_SEQ_SetTask( UTIL_SEQ_bm_t TaskId_bm , uint32_t Task_Prio ) function.
But in the end, the sequencer is a loop. So all tasks should be executed.
In our examples, all our tasks have the same priority.
2020-08-19 11:52 AM
That is, I can put my function (Effect_1) in a task with a low priority and call it in an infinite loop(i.e. in main) ? Then BLE event will stay in a higher priority?
2020-08-21 05:42 AM
the low power mode didn't stop the reception of the event concretelly, but has stopped the loop, that is, when the program enters in the loop it gets stuck in the wait function while there is no event . And at this moment the loop doesn't go forward as it should go. I would like so as to while the system waits for the event the loop runnned.
2020-08-28 08:50 AM
Please find a basic presentation of the sequenceur. the last 2 pages could be a way to do what you want.
You have to overload the UTIL_SEQ_EvtIdle() function (have a look at the BLE examples)
void UTIL_SEQ_EvtIdle( UTIL_SEQ_bm_t task_id_bm, UTIL_SEQ_bm_t evt_waited_bm )
{
UTIL_SEQ_Run( UTIL_SEQ_DEFAULT );
}
This enables all tasks to run (even re-entering in the current task)
The implementation by default is
__WEAK void UTIL_SEQ_EvtIdle( UTIL_SEQ_bm_t TaskId_bm, UTIL_SEQ_bm_t EvtWaited_bm )
{
UTIL_SEQ_Run(~TaskId_bm);
return;
}
This allows all tasks to run except the current one.