2025-10-21 6:32 AM - edited 2025-10-21 7:25 AM
Apologies for cross post, I couldn't find a way to delete the other post or how to change which board to post it to.
I'm trying to set up the Utility Sequencer to run an acquisition task followed by an signal processing task, see code snippets below.
When I look at the serial monitor, I see the start acquisition task message but then it hangs waiting for EVENT0
So even though I've set EVENT0 in Custom_APP_Init() it looks to me that the event is not in fact set.
What am I missing here?
I commented out the SetTask line as I realized I hadn't finished setting up before the sequencer sets off but now no tasks get set, so I dont get the start acquisition task message any more.
#define EVENT0 1<<30
#define EVENT1 1<<31
void Custom_APP_Init(void)
{
/* USER CODE BEGIN CUSTOM_APP_Init */
UTIL_SEQ_RegTask(1<<CFG_TASK_SENSOR_UPDATE_ID, UTIL_SEQ_RFU, sensor_update);
UTIL_SEQ_RegTask(2<<CFG_TASK_FFT_ID, UTIL_SEQ_RFU, do_fft);
UTIL_SEQ_SetEvt(EVENT0);
// UTIL_SEQ_SetTask(1<<CFG_TASK_SENSOR_UPDATE_ID, 0);
/* USER CODE END CUSTOM_APP_Init */
return;
}
void sensor_update(void)
{
printf("start acquisition task\n\r");
UTIL_SEQ_WaitEvt(EVENT0);
printf("In acquisition task\n\r");
/* DAQ code */
UTIL_SEQ_ClrEvt(EVENT0);
UTIL_SEQ_SetEvt(EVENT1);
}
void do_fft(void)
{
UTIL_SEQ_WaitEvt(EVENT1);
/* FTT code */
UTIL_SEQ_ClrEvt(EVENT1);
UTIL_SEQ_SetEvt(EVENT0);
}
UPDATE:
2025-11-24 3:58 AM
Hello @NicRoberts,
you have UTIL_SEQ_WaitEvt function in the body of the task. That means that when the task is executed and the line with UTIL_SEQ_WaitEvt comes, the sequencer suspends the task and waits until the event is triggered by SetEvt function. However, the event must be requested first and therefore your code is stuck after executing the Sensor update task.
Also, your code does not call the FFT task at any time because tasks are executed only via UTIL_SEQ_SetTask function.
For more information about sequencer, you can refer to Understanding STM32 Sequencer where you can find some useful links.
If you have any further question, please let me know
Best regards
grohmano