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.

RTOS/TM4C1294NCPDT: Timer and UART communication at 1 ms in TI-RTOS

Part Number: TM4C1294NCPDT

Tool/software: TI-RTOS

Respected sir/madam,

I want to do uart communication at every 1 ms. I have created 1 ms timer thread. But when i try to call any function related to uart like UART_write  etc or  my_uart function which does uart communication i get the following error.

n failure: A_badContext: bad calling context. See GateMutex API doc for details.
xdc.runtime.Error.raise: terminating execution

I know that i am getting this error because i am trying to call functions like create , delete from Hwi thread. So what is the solution for this problem??  How should i proceed with my programming??

regards,

digvijay

  • HI, Digvijay,

    The timer callback is executing in an interrupt context. You cannot call UART_write in this context. It must be called in a task (I'm assuming you are using TI-RTOS). You can use UART_writePolling.

    More common ways to do this is have a task that does something like this pseudo-code

    task

    {

       while (1) {

           Semaphore_pend(semHandle);

           UART_write(...)

       }

    }

    Then create a Clock object that calls Semaphore_post(semHandle). Set the Clock object to run at 1ms. Note: by default TI-RTOS uses a timer to drive a 1ms tick (the period is configurable, but most customers leave it at 1ms).

    Todd

  • thanks,

    regards,

    digvijay.