Skip to main content
TomC
Senior
March 10, 2021
Question

Integration of an existing project into the sequencer (UTIL_SEQ)?

  • March 10, 2021
  • 5 replies
  • 10354 views

I wish to add BLE functionality to an existing project on an STM32WB55. It appears that use of the sequencer (UTIL_SEQ) is encouraged if not mandatory for employing the BLE coprocessor on the WB55.

My understanding of the sequencer is that it's simply an optimized while loop and so any existing interrupts (Timers & DMA) I have utilized will continue to function as normal and I should take what's running in my current super loop (while(1) loop) and slot them into functions that I then register as tasks and set with the sequencer.

Are the assumptions I've made regarding interrupts correct and is the approach of integration I have described straight forward and reasonable?

Here is a list of resources I've found relating to use of the sequencer with the STM32WB55:

STM BLE Tutorial

Building wireless applications with STM32WB Series microcontrollers

STM32WB Bluetooth® Low Energy (BLE) wireless interface

STM32WB – BLE SW Application Architecture

5 replies

TomC
TomCAuthor
Senior
March 11, 2021

I am also wondering if I need unique flags for tasks if I don't intend to pause/resume any tasks before their completion

TomC
TomCAuthor
Senior
March 11, 2021

I am wondering as well how best to reset tasks that I want to always be set without causing other tasks to starve

ST Employee
March 14, 2021

Hello,

I am not sure about the meaning of "reset tasks". Regarding tasks starving, there is a round robin mechanism that ensures that each task has some opportunity to run is all associated flags are set for ever ( assuming they all have the same priority).

That would be great if you could post a simple example to illustrate your query.

Regards.

ST Employee
March 14, 2021

Hello,

Your understanding of what the sequencer is doing and what you would need to do to migrate your application on top of it is perfect.

It is correct as well that it will change nothing regarding code execution in your interrupt handler.

Regards.

TomC
TomCAuthor
Senior
March 15, 2021

Thank you for your response. Was I correct in assuming that it's recommended that the BLE peripheral for a STM32WBXX should be implemented using the sequencer. I say this as the code generated when you activate the BLE peripheral using CUBEMX is already integrated into the sequencer.

ST Employee
March 16, 2021

Hello,

Generally speaking, it is recommended to use the Sequencer for any bare metal application running on any STM32. it provides the required mechanism to avoid race condition ( especially when entering low power mode).

CubeMx generates bare metal application based on the Sequencer. It is possible to implement a BLE application without the Sequencer ( this is done in BLE_Peripheral_Lite project) but in that case, you will get no CubeMx support to generate the full application. CubeMx could still be used to generate some part of code to use a peripheral and you will then need to merge this code in your dedicated application.

However, as long as there is no reason to not go with the Sequencer, it is strongly advised to use it.

Regards.

TomC
TomCAuthor
Senior
March 17, 2021

Okay thank you Christophe I will preference use of the sequencer.

Finally, and please advise me if I should move this into a new post, I am finding that if I register several tasks with my sequencer in a project that utilizes the BLE peripheral, configured as per this tutorial, my device (STM32WB55) will no longer advertise consistently to either an Android or iOS device running the "ST BLE Sensor" mobile application. I find that if I register fewer tasks that the device will advertise reasonably well and am also able to reliably get example projects working.

All of my tasks are of the same priority (1) and I believe the BLE Advertisement Request, by default (CUBEMX), is the highest priority (0). I was wondering if increasing the number of registered tasks will indeed affect the BLE advertising behaviour or if it's perhaps the contents of one or more of these tasks. My understanding is that the BLE Advertisement, by default (CUBEMX), is triggered by an interrupt and advertises for 60 seconds at a time, and that it will continue to interrupt and advertise while ever the program is running.

It's not obvious to me the mechanism by which these tasks which, I believe, are of lower priority than the BLE advertisement, affect its behaviour. Furthermore, if the BLE Advertisement executes only once initially, I am not seeing evidence of this behaviour either. Additionally, if the device is able to advertise I receive the error message "Error during the connection with the node [device name]".

TomC
TomCAuthor
Senior
March 17, 2021

Re: BLE Advertising fails when adding tasks.

This was caused by using the same task IDs for my own tasks as were used by the BLE tasks in the code generated by CUBEMX. I believe the BLE tasks were using values 0 & 2, so my own task IDs are all 20 or greater just to be sure.

AM.12
Associate III
March 3, 2023

Hello @Community member​ , @Christophe Arnal​ .

I am facing a problem related to this post, I was searching for the solution and I came across this post.

I am working on STM32WB55 custom board. I have configured it in STOP2 low power mode.

when the device wakes up due to EXTI if I try to use HW_TS_Start or UTIL_SEQ_SetTask. device Hangs up.

Can you suggest me what I am missing in configuration

Associate II
September 25, 2024

First link is not working. I also bought the stm32wb55 dk board. I dont know where to start. Prior to this I was using While loop and the HAL layer. Its quite overwhelming to me. 

Associate II
September 25, 2024

Hi @nayeemcron 

Here's what has been working pretty well for me 

  • Create your regular application as a state machine that returns as frequently as possible. Lets say App_Sm()
  • Create a TaskSequenceWrapper() that runs App_Sm, and sets the sequencer to run it through UTIL_SEQ_SetTask()
  • Register the TaskSequenceWrapper() with the sequencer through UTIL_SEQ_RegTask() at APP_BLE_Init()

This way your BLE sequencer both schedules your App_Sm() to run, and if its granular enough, be responsive enough for BLE events as well. 

I would be happy to hear alternate implementations if any. 

Associate II
September 25, 2024

Hi Vishal, 
thank you for your reply.
Could you explain a bit more in details.