Hi guys, I need a little bit of help.
I have to move all my code, on SAM L21 microcontroller.
But how it's possible to reload a TC timer set as one shot mode ?
I used the wizard examples and everything has been good for other peripherals. But not for this timer.
It works perfectly as one shot, but later after the first time, I didn't understand how to reload it.
I have to reload it on every uart data received so, after the right period, I 'm going to have a elapsed interrupt to understand the modbus end of frame.
If you need more details, no problem.
Thanks in advance.
Attilio
// INIT TIMER bool TC4_Inizialize(void) { bool ret_val = false; TC4_TimerStru.interval = GetModbusEndOfFrameTime(); -> about 3,6 ms with baud = 9600 TC4_TimerStru.cb = TC4_ModbusEndOfFrame_Handler; TC4_TimerStru.mode = TIMER_TASK_ONE_SHOT; if(timer_add_task(&NEWTIMER_TC4, &TC4_TimerStru) == ERR_NONE) { if(timer_start(&NEWTIMER_TC4) == ERR_NONE) { ret_val = true; } } return ret_val; } // this function is called on every received char void ReloadModbusEoFTimer(void) { // here I have to reload the timer, so after 3.5 char of silence (no reload), I will have the TC4 handle } // HANDLE TIMER static void TC4_ModbusEndOfFrame_Handler(const struct timer_task *const timer_task) { ModbusAvailableFrameFlag = true; // ecc. ecc. }