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.

CC1312R: Sub-1 GHz forum

Part Number: CC1312R

I've implemented a UART example using driverlib from SDK3.20.00.68, and can't get the Rx interrupt to work.   I am able to poll using UARTCharsAvail, and properly receive a character.  But the ISR is never hit.

Here's the code:

 

UARTDisable(UART0_BASE);

UARTConfigSetExpClk(UART0_BASE, CPU_CLOCK_HZ, baud, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);

UARTFIFOEnable(UART0_BASE);

UARTHwFlowControlDisable(UART0_BASE);

UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);

UARTIntEnable(UART0_BASE, UART_INT_RT | UART_INT_RX);

UARTIntRegister(UART0_BASE, INTRX_DEBUG_IRQHandler);

UARTIntClear(UART0_BASE, UART_INT_OE | UART_INT_BE | UART_INT_PE | UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX | UART_INT_CTS);

UARTEnable(UART0_BASE);

 

if (UARTCharsAvail(UART0_BASE))

{   

receive[j] = UART_GetByte(0);

UART_TXByte(empty, receive[j]);

}

 

void INTRX_DEBUG_IRQHandler(void)

{

receive[j] = UART_GetByte(0);

UART_TXByte(empty, receive[j]);

}

 

  • Hi Hendrix,

    Is there a reason you're using driverlib instead of TI Drivers? 

    With TI Dtivers you could  use UART_MODE_CALLBACK and it will trigger interrupt on UART TX and RX. You will find some example in SDK docs: file:///C:/ti/simplelink_cc2640r2_sdk_1_40_00_45/docs/tidrivers/doxygen/html/_u_a_r_t_c_c26_x_x_8h.html

    Thanks,

    Alexis

  • I'm helping a customer who wants to keep things very low-level, thus the driverlib approach.  I can get the TI driver examples to work, but there don't seem to be any examples that use driverlib directly.   

    Since the UART is working, it's only the interrupt piece that's an issue.  It appears that UARTIntRegister puts the vector in SRAM, not the flash vector table.  But even if I manually put the vector in the flash table (in startup_ccs.c), I don't get interrupts.  

    I forgot to include it above, but I'm also enable global interrupts with this:

    IntEnable(INT_UART0_COMB);
    IntPendClear(INT_UART0_COMB);
    IntMasterEnable();

  • Hendrix,

    Sorry for the delay...apps will come back to this post asap.

  • Hi Hendrix,

    I did some digging into the TI Driver implementation and this is how it sets up the HWI to process UART interrupts on the back end using driverlib:

    *  ======== UARTCC26X2_hwiIntFxn ========
     *  Hwi function that processes UART interrupts.
     */
    static void UARTCC26X2_hwiIntFxn(uintptr_t arg)
    {
        uint32_t                    status;
        UARTCC26X2_HWAttrs const    *hwAttrs = ((UART_Handle)arg)->hwAttrs;
    
        /* Clear interrupts */
        status = UARTIntStatus(hwAttrs->baseAddr, true);
        UARTIntClear(hwAttrs->baseAddr, status);
    
        if (status & (UART_INT_RX | UART_INT_RT | UART_INT_OE | UART_INT_BE |
                UART_INT_PE | UART_INT_FE)) {
            readIsr((UART_Handle)arg, status);
        }

    Perhaps you can try something like this?

    Thanks,

    Alexis

  • I tried this, but evidently there is more that needs to be done to initialize the interrupts.  The code above requires the UART_Handle to be setup, which is not part of driverlib.   

  • Hi,

    Here is the setup sequence I am using and am able to hit the interrupt:

        //
        // Disable processor interrupts.
        //
        IntMasterDisable();
        
        //
        // Disable UART function
        //
        UARTDisable(UART0_BASE);
    
        //
        // Disable all UART module interrupts
        //
        UARTIntDisable(UART0_BASE, UART_INT_OE | UART_INT_BE | UART_INT_PE |
                                   UART_INT_FE | UART_INT_RT | UART_INT_TX |
                                   UART_INT_RX | UART_INT_CTS);
    
        //
        // Map UART signals to the correct IO pins and configure them as
        // hardware controlled.
        //
        IOCPinTypeUart(UART0_BASE,EXAMPLE_PIN_UART_RXD,EXAMPLE_PIN_UART_TXD,
                       EXAMPLE_PIN_UART_CTS,EXAMPLE_PIN_UART_RTS);
    
        //
        // Configure the UART for 115,200, 8-N-1 operation.
        // This function uses SysCtrlClockGet() to get the system clock
        // frequency. This could be also be a variable or hard coded value
        // instead of a function call.
        //
        UARTConfigSetExpClk(UART0_BASE, GET_MCU_CLOCK, 115200,
                            (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                             UART_CONFIG_PAR_NONE));
            
        // 
        // Enable UART
        // Enables FIFO with a default trigger level of 4/8 * 32 samples
        //
        UARTEnable(UART0_BASE);
    
        //
        // Disable FIFO to allow interrupt on first character.
        //
        UARTFIFODisable(UART0_BASE);
        
        
        //
        // Enable RX interrupt of UART module
        //
        UARTIntEnable(UART0_BASE, UART_INT_RX);
    
        //
        // Enable the UART0 interrupt on the processor (NVIC).
        //
        IntEnable(INT_UART0_COMB);
        
        //
        // Enable processor interrupts.
        //
        IntMasterEnable(); 
    
    Interrupt handler below
    
    void
    UART0IntHandler(void)
    {  
        char cThisChar;
        
        //
        // Clear the UART interrupt flag.
        //
        UARTIntClear(UART0_BASE, UART_INT_RX);
        
        //
        // Read a character using the non-blocking read function.
        //
        cThisChar = UARTCharGetNonBlocking(UART0_BASE);
        
        //
        // Write the same character using the non-blocking write function.
        //
        UARTCharPutNonBlocking(UART0_BASE, cThisChar);
    //    UARTCharPutNonBlocking(UART0_BASE, '\n');
    }