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.

TM4C129ENCPDT: UART Read Callback mode - how to get ISR to fire even when in a different task?

Part Number: TM4C129ENCPDT

Tool/software:

Hello,

I have configured UART 4 to read in callback mode. After setting up this task, I jump over to the tcp task.

I want to capture incoming UART traffic in a software FIFO regardless of what task is running. But, the ISR doesn't fire when I send UART traffic (USB to UART FTDI bridge).

This was working when I wasn't using the TI RTOS, but now that I'm using tasks, the ISR doesn't fire. Can you tell me what I'm doing wrong? Thank you.

void InitRs485BusUartTask
(
Mailbox_Handle* rs485MbPtr  ///< Pointer to mailbox handle
)
{

    if (rs485MbPtr)
    {
        AssignMb(&rs485BusSys.uartSysVars_Tx.rs485Handle, rs485MbPtr);
    }

    const char echoPrompt[] = "\fUART 4 is online!:\r\n";

    InitUartParams(&rs485BusSys.uartParams);//, &rs485BusSys.initStatus);

    volatile bool mailboxPendSuccess = false;

    rs485BusSys.handle = UART_open(Board_UART4, &rs485BusSys.uartParams);
    if (rs485BusSys.handle == NULL) {
        System_abort("Error opening the UART 4");
    }
    


    UART_read(rs485BusSys.handle, rs485BusSys.inputString, 1);

    Task_Params_init(&rs485BusSys.uartSysVars_Rx.taskParams);
    rs485BusSys.uartSysVars_Rx.taskParams.stackSize = TASKSTACKSIZE;
    rs485BusSys.uartSysVars_Rx.taskParams.stack = &rs485BusSys.uartSysVars_Rx.task0Stack;
    rs485BusSys.uartSysVars_Rx.taskParams.instance->name = "rs485BusUart_Rx";
    rs485BusSys.uartSysVars_Rx.taskParams.priority = UART_RX_TASK_PRIORITY;//1; //TODO need to give thought to the priority of this task. Currently, this task is "running" and tcp is "ready"
    Task_construct(&rs485BusSys.uartSysVars_Rx.task0Struct, (Task_FuncPtr)rs485BusUartFxn_Rx, &rs485BusSys.uartSysVars_Rx.taskParams, NULL);
    
    System_printf("Starting the UART Echo example\nSystem provider is set to "
                  "SysMin. Halt the target to view any SysMin contents in "
                  "ROV.\n");
    /* SysMin will only print to the console when you call flush or exit */
    System_flush();    
}

//=============================================================================
/**
@return
- Void

Task that handles the reception side of the UART. This receives messages in
from the RS-485 bus to the UART.
*/
Void rs485BusUartFxn_Rx
(
UArg arg0,  ///< TI RTOS argument 0
UArg arg1   ///< TI RTOS argument 1
)
{


    //const char echoPrompt[] = "\fUART 4 is online!:\r\n";

    //InitUartParams(&rs485BusSys.uartParams, &rs485BusSys.initStatus);



    volatile bool mailboxPendSuccess = false;
    volatile int32_t readRtnVal = 0;
    int32_t fifoSize = 0;
    static uint8_t rxBuffer[GENERIC_TEST_FIFO_SIZE];





    /* Loop forever echoing */
    while (1)//0 < (fifoSize = GetSizeGenericFifo(&rs485BusSys.rxFifo)))
    {
        fifoSize = GetSizeGenericFifo(&rs485BusSys.rxFifo);
        
        if (0 < fifoSize)
        {
            PopGenericFifo(&rs485BusSys.rxFifo, rxBuffer);
            
            //Post this to the RS485 to Parse mailbox
            
            //Put the task to sleep
        }

        //readRtnVal = UART_read(rs485BusSys.handle, rs485BusSys.inputString, RS485_BUFFER_SIZE);
        //else
        //{
            //Task_sleep(1);
        //}
    }




}

//=============================================================================
/**
@return
- void

Callback function to address incoming UART traffic for the RS485 bus.
*/
static void Rs485UartReadCallback
(
UART_Handle handle,    ///< Rs485 UART handle
void *rxBuf,         ///< Receive buffer
size_t size            ///< Size of received message within the buffer
)
{
    if ((size) && (rxBuf) && (handle))
    {
        if (RS485_BUFFER_SIZE == size)
        {
            PushGenericFifo(&rs485BusSys.rxFifo, rxBuf);
        }
    }
}

  • Hi Noah,

      Are you using the interrupt? Did you enable the interrupt?

  • My apologies. I forgot to include the UART Init function. Yes, I have enabled the interrupt through this init call:

    static int32_t InitUartParams
    (
    UART_Params* params ///< Pointer to UART Parameters

    )
    {
    int32_t returnVal = -1;

    if (params)// && status)
    {
    returnVal = 1;

    //if (*(status) == uart_init)
    //{
    // returnVal = 2;
    //}
    //else
    {

    //*(status) = uart_init;

    /* Create a UART with data processing off. */
    UART_Params_init(params);
    params->writeDataMode = UART_DATA_BINARY;
    params->readDataMode = UART_DATA_BINARY;
    params->readReturnMode = UART_RETURN_FULL;
    params->readEcho = UART_ECHO_OFF;
    params->readMode = UART_MODE_CALLBACK;
    params->readCallback = Rs485UartReadCallback;
    params->baudRate = RS485_UART_BAUD_RATE;
    }

    }

    return returnVal;
    }

  • Hi Noah,

      I think you would need to call UART_read() in order for the Rs485UartReadCallback to be called. Can you try a simpler program where you call UART_read  to see if the callback is called. It is easier to isolate the problem. 

  • Hi Noah,

      I have not heard back from you.  I will close the thread for now. If you have any update, you can write back to this post and the status will change to OPEN.