Showing results for 
Search instead for 
Did you mean: 

How to add new sequencer

Associate III

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_SetPeriod(&accelMovementTimer,10); //10ms

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

typedef enum
  /* USER CODE END CFG_SEQ_Task_Id_t */
} 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 ?

Lead II

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) 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);

Associate III

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.

Lead II

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.




sound like good ones to look at.

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