Skip to main content
AHakk.1
Associate III
Apr 12, 2023 12:31 PM UTC
Question

How to add new sequencer

Hello everyone, I am working with 3 stm32wl55JC module. 1 is receiver the other 2 is transmitter. The code has

 UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_Sensor_Process), 0, Sensor_Process);

I want to add another task which needs to work as endless loop. The task is accelerometer and it works at 20Hz.

UTIL_TIMER_Create(&accelMovementTimer,0xFFFFFFFF,UTIL_TIMER_PERIODIC,movement_Process,NULL);
 UTIL_TIMER_SetPeriod(&accelMovementTimer,10); //10ms
 UTIL_TIMER_Start(&accelMovementTimer);

I can get this task work with timer but I want to use sequencer. So I added this on utilities_def.h

typedef enum
{
 CFG_SEQ_Task_Sensor_Process,
 /* USER CODE BEGIN CFG_SEQ_Task_Id_t */
 CFG_SEQ_Task_movement_Process,
 
 /* USER CODE END CFG_SEQ_Task_Id_t */
 CFG_SEQ_Task_NBR
} CFG_SEQ_Task_Id_t;

and this line on subghz_phy_app.c

UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_movement_Process), 0, movement_Process);

My question is how can I add this task properly ?

This topic has been closed for replies.

3 replies

Danish1
Lead III
Apr 14, 2023 8:54 AM UTC

As no-one else has jumped in, I'll try to answer this. You should refer to the ST application note AN5289 (written for Bluetooth) https://www.st.com/resource/en/application_note/dm00598033-building-wireless-applications-with-stm32wb-series-microcontrollers-stmicroelectronics.pdf because I don't know where else the sequencer is documented.

The sequencer is based on the idea of "co-operative multitasking". You register a task and tell the sequencer that it needs to run, then (when no other task is running) that one will be run. Once.

At any moment there an interrupt could fire, and the stm32 processor momentarily stops what it was doing (if anything) with the sequencer and services the interrupt. There are restrictions on what an interrupt-service-routine (ISR) can or should do, for example if it pauses waiting for a peripheral to be ready, there's NOTHING else the processor can do. And it it tries to log helpful information, the logger might become full as that doesn't get a look-in.

You have created and started a timer with your UTIL_TIMER_Create stuff, which will cause a call to an ISR. That ISR should NOT have the same name as your process - perhaps call it movement_trigger_ISR. In your case it looks to be periodic. Inside movement_trigger_ISR you should tell the sequencer to run your task with UTIL_SEQ_SetTask:

UTIL_SEQ_SetTask(1 << CFG_SEQ_Task_movement_Process, CFG_SEQ_Prio_movement_Process);

AHakk.1
AHakk.1Author
Associate III
Apr 24, 2023 4:57 AM UTC

Thanks for answer. I want to ask 1 more thing. I want to use microphone and accelerometer with Nucleowl55jc. I don't have a experience with C and STM boards. I wrote the functions and I can run microphone and accelerometer but I have a problem. Microphone collect 128 sample at 63 ms with arduino, how can I create something like this. I mean I can't create

 UTIL_TIMER_SetPeriod(&accelMovementTimer,0.1); //0.1 ms

something write? What is the correct way to do that? This might be easy question, sorry.

Danish1
Lead III
Apr 24, 2023 10:48 AM UTC

As far as I know, UTIL_TIMER can only cope with whole-number-of-millisecond delays/periods, and there is a minimum allowable delay of 3 ms.

You could usefully explore the other examples.

ADC_SingleConversion_TriggerSW_IT

or

ADC_SingleConversion_TriggerTimer_DMA

sound like good ones to look at.

But you will have to get used to the C language!