You are using a hardware interrupt to generate the soc input of the SAR. Are you performing any API calls to the Timer outside the ISR? If so, you may be unintentionally resetting and clearing the Timer register preventing the ISR from being executed. This might be the equivalent of the "chicken and egg" problem.
Additionally, are you changing the period value to different values? If not, don't execute Timer_WriteCounter(Timer_INIT_PERIOD); It's not needed.
If you want to generate 10ms soc signal with less CPU intervention, set the Period to 10000 and connect the soc input to the tc output of the Timer.
Once you start it with your above code, the ISR is not needed. The soc input will get a strobe every 10ms without further CPU intervention. As long as the Timer is not stopped, the Timer will reload the Period itself and start the counting over again and again. This is much simpler and more dependable and doesn't depend on having enough CPU bandwidth or if you accidentally turned off Global interrupts.
Hi Len ,
Thank you for the reply .
Q- Are you performing any API calls to the Timer outside the ISR?
Ans - No , This timer is only used for SAR
Q - are you changing the period value to different values?
Ans - No , But Timer_WriteCounter(Timer_INIT_PERIOD); is used to get exact 10ms after reading ADC data .
Using TC instead of an ISR is a very good suggestion .
The problem I am facing is this issue is not reproducible , unit will run days without any issue . Interestingly all other ISR and FreeRTOS tasks are running properly during this issue . Only this timer stopped .
By using the Timer's TC only instead of the ISR, you eliminate potential CPU generated issues. It's all HW driven once the HW is launched (started). If you also place a output pin attached to the TC output, you can monitor if the Timer is stopped.
If the Timer is stopped, TC will not pulse. If the Timer is not stopped but the ADC conversions have stopped, the problem is on the ADC side of the SW (or HW). Likewise, you can place a output pin on the ADC EOC output to monitor the HW state of the ADC.