Skip to main content
August 7, 2020
Question

Problem with advertising when using HAL_Delay in main funcion.

  • August 7, 2020
  • 22 replies
  • 3688 views

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?

This topic has been closed for replies.

22 replies

August 14, 2020

Thanks very much for the datailed answer. I'm going to try the wait_event functionality.

August 17, 2020

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?

Remi QUINTIN
Technical Moderator
August 18, 2020

Did you get the interrupt?​

Remi QUINTIN
Technical Moderator
August 19, 2020

​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?

August 19, 2020

here is the loop

0693W000003PnAbQAK.png

and here the recepetion of the data

0693W000003PnBAQA0.png

Remi QUINTIN
Technical Moderator
August 19, 2020

​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.

August 19, 2020

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?

August 21, 2020

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.

Remi QUINTIN
Technical Moderator
August 28, 2020

​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.

Remi QUINTIN
Technical Moderator
August 28, 2020