This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM62P: Timer: feasibility of driver calling in Timer ISR

Part Number: AM62P

Hi,
 
Our customer want to use uart_driver in timer interrupt in order to send data via uart periodicly. Now I could successfully configure a timer in MCU domain and the callback function of timerer could be entered as expected. However, I think calling uart_driver in ISR is not allowable because this is likely to cause stackoverflow, which leads to unpredicted behaviours. I want to double-check whether my statement is correct or not? I would appreciate it if you have alternative solutions to share.
The MCU+SDK version I am using is 11.01.01.08 and the uart_driver is configured as callback mode.
 
Regards,
Bomiao  
  • Hi Fan,

    Using Uart in callback mode inside your Timer ISR routine is okay, as you are not going ahead with UART's blocking or polling mode of operation. But there are few pointers you need to take care of.

    • Re-entrancy guard: UART_write() uses HwiP_disable()/restore() to check if a transfer is already in progress. If you call it from the timer ISR while a previous transfer hasn't completed yet, it returns SystemP_FAILURE (busy).
    • Callback executes in UART ISR context: Your write-complete callback runs inside the UART HW interrupt, not the timer ISR. Keep it lightweight.

    Regards,

    Vaibhav