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.

CC3220SF-LAUNCHXL: UART Interrupt Issues

Part Number: CC3220SF-LAUNCHXL
Other Parts Discussed in Thread: CC3220SF

Hi!

I'm using the CC3220SF with SDK Version 2.40.02.00. My project is based off of the FreeRTOS provisioning example. I am trying to use UART0 RX interrupt, but I can't get the callback function to run. I've configured my UART as shown in the InitTerm function below, and for now my callback function is just printing to the terminal that the callback was triggered. Basically, I need that callback function to run when a character is received over UART. It needs to be interrupt driven so that it does not interfere with other threads that are running.

UART_Handle InitTerm(void)
{
    UART_Params uartParams;

    UART_init();
    UART_Params_init(&uartParams);

    uartParams.readMode = UART_MODE_CALLBACK;
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 115200;
    uartParams.readCallback = UART_Callback_Test;

    uartHandle = UART_open(Board_UART0, &uartParams);
    /* remove uart receive from LPDS dependency */
    //UART_control(uartHandle, UART_CMD_RXDISABLE, NULL);

    return(uartHandle);
}

void UART_Callback_Test(){
    LOG_MESSAGE("UART Int Triggered");
}

  • Hi Brian,

    The way that the UART driver will work in callback mode is that you have to issue a UART_read() to uartHandle first to enable the interrupt, and then when the specified number of bytes have been read then the callback will be triggered. Have you done this UART_read()?

    I suggest you take a look at the uartecho example and then modify it to use a callback. See my post here for reference: https://e2e.ti.com/support/wireless-connectivity/wifi/f/968/p/732341/2702996#2702996

    Let me know if you need more clarification on our UART drivers, or if you have more questions on this topic.

    Regards,

    Michael

  • Hi Michael,

    It seems as though any time I call UART_read() my program gets thrown into a faultISR and is stuck in a while(1) that does nothing and stops the program from doing anything else. I could use some help figuring out why that happens. The InitTerm function that you can see above has been called before the UART_read function is called. I'm not sure what else would cause this to happen.

  • After messing around a bit I've solved my issues.
    1) My uartHandle was defined to be static, I took that away and I stopped getting the fault isr.
    2) In my UART_Callback_Test() I set a flag that lets the program know whether a character has been received or not
    3) I created a thread that has a while(1) loop checking that flag. If there is a character received that needs to be processed, run the user application (be sure to reset the character received flag). If there is not a character, then continue checking the flag until there is a character. I had to add a vTaskDelay to the while(1) loop to stop it from blocking the other threads.