7. How to use Timer Interrupts in 1SJ LoRa Device?

Next, let us take a look at the UTIL Task Sequencer inside the same LoRaWAN_Init function. As seen in the blue box below, the main task managed by the task sequencer is to send transmission data (SendTxData). However, if an interrupt occurs as seen in the red box below, the callback function OnTxTimerEvent will be called.

Inside the callback function OnTxTimerEvent seen below, the task sequencer will execute the task set just before SendTxData function in the main task using UTIL_SEQ_SetTask seen below, followed by resetting the TxTimer again for the next transmission with the function UTIL_TIMER_Start.

Once this task is complete, the task sequencer will return back to do its main task which is to send transmission data (SendTxData).
How to register task in Task Sequencer?
Head back to the LoRaWAN_Init function, highlight the function UTIL_SEQ_RegTask, right click and click Go To Definition as seen below.

It brings us to stm32_seq.c file where we can see the function UTIL_SEQ_RegTask defined.

The 3 parameters required are:
| |
1. |
Task ID - Defined inside utilities_def.h file |
| |
2. |
Flags - Reserved parameter for future use |
| |
3. |
Task Reference - Function to execute inside the task sequencer |
So as seen in the main task function (blue box) below:
| |
1. |
Task ID → CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent |
|
2. |
Flags → UTIL_SEQ_RFU |
|
3. |
Task Reference → SendTxData function to be executed |
|
|

|
How to add a new Task?
We will head to utilities_def.h file to define the Task ID at line 81 area.
