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.

CCS/OMAP-L138: C6748 UARTTX interrupt happens only once.

Part Number: OMAP-L138


Tool/software: Code Composer Studio

Hello, everyone.

I am trying to communicate UART on ccs 8.3.1 with pdk 1.0.9 version, using the omap-l138 board.

First, I created 3 examples related to UART using pdkProjectCreate.sh.
  1. UART_BasicExample_lcdkOMAPL138_c674xExampleProject
  2. UART_BasicExample_lcdkOMAPL138_c674xTestProject
  3. UART_BasicExample_lcdkOMAPL138_c674xDMATestProject

Among these, I tested the Uart Polling method using No.1 and now I'm trying the Interrupt method using No.2.

For interrupt method, I added the source code by referring to ~pdk/packages/ti/csl/example/uart/intr/main.c in Example code 2 (UART_BasicExample_lcdkOMAPL138_c674xTestProject)

The codes added or modified are as follows:

void uartIsr()
{
    static uint32_t txStrLength = sizeof(txArray);
    static uint32_t count       = 0;
    uint32_t        intId       = 0;
    rxByte      = 0;

    intId = UART_intIdentityGet_v0(CSL_UART_2_REGS);
    
    switch(intId)
    {
        case UART_INTID_TX_THRES_REACH:
            if( 0 != txStrLength)
            {
                UART_charPut_v0(CSL_UART_2_REGS, txArray[count]);
                txStrLength--;
                count++;
            }
            else
            {
                UART_intDisable_v0(CSL_UART_2_REGS, UART_INT_THR );
            }

            break;

        case UART_INTID_RX_THRES_REACH:
            buffer[++bufferIdx] = UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
            UART_charPut_v0(CSL_UART_2_REGS, buffer[bufferIdx]);
            break;

        case UART_INTID_RX_LINE_STAT_ERROR:
        case UART_INTID_CHAR_TIMEOUT:
            UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
            break;

        default:
            break;

    }
}

void uart_test(UArg arg0, UArg arg1)
{
    UART_Handle     uart = NULL;
    UART_Params      uartParams;
    int              length = 0;
    uintptr_t         addrDataPrint, addrScanPrompt, addrEchoPrompt;
    UART_Transaction transaction;
    bool             ret = false;
    UART_HwAttrs uart_cfg;

    printf("Starting Uart test \n");
    UART_init();
    UART_socGetInitCfg(uartTestInstance, &uart_cfg);
    UART_osalSemParamsInit(&semParams);
    semParams.mode = SemaphoreP_Mode_BINARY;
    callbackSem = UART_osalCreateBlockingLock(0, &semParams);

    /* UART SoC init configuration */
    UART_initConfig(false);
    UART_Params_init(&uartParams);
    uartParams.baudRate =115200;
    uart_cfg.edmaHandle = NULL;
    uart_cfg.dmaMode = FALSE;
    uart_cfg.enableInterrupt=1; /* Enabling interrupt forcefully */

    /* Get the default UART init configurations */
    UART_socSetInitCfg(uartTestInstance, &uart_cfg);
    uart = UART_open(uartTestInstance, &uartParams);

    if(uart == NULL)
    {
        if(uart)
        {
            UART_close(uart);
        }
    }

    Intc_Init();
    IntEventCombineInit(ECM0_UNUSED, ECM1_UNUSED, C674X_MASK_INT4, ECM3_UNUSED);
    IntEventCombineRegister(69, (c674xISR)uartIsr);
    IntEventCombineAdd(69);
    Intc_SystemEnable();
    UART_intEnable_v0(CSL_UART_2_REGS,(UART_INT_LINE_STAT | UART_INT_THR |
            UART_INT_RHR_CTI) );

    while(1)
    {  
    }
}

I added the following code after seeing ~pdk/packages/ti/csl/example/uart/intr/main.c.

Intc_Init();
IntEventCombineInit(ECM0_UNUSED, ECM1_UNUSED, C674X_MASK_INT4, ECM3_UNUSED);
IntEventCombineRegister(69, (c674xISR)uartIsr);
IntEventCombineAdd(69);
Intc_SystemEnable();
UART_intEnable_v0(CSL_UART_2_REGS,(UART_INT_LINE_STAT | UART_INT_THR |
            UART_INT_RHR_CTI) );

+ uartIsr code

I could check the UART Interrupt.

It generates the following transmission interrupts at the same time as the start:

char txArray[] = "PDK UART Interrupt application\n\r";
After that, it receives text from the terminal and prints it out to the terminal.
        case UART_INTID_RX_THRES_REACH:
            buffer[++bufferIdx] = UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
            UART_charPut_v0(CSL_UART_2_REGS, buffer[bufferIdx]);
            break;

I have a question here.

Only the first one transmission interrupt occurs, and not thereafter.
It only prints one byte of received immediately through the interrupt.
Data stored in buffers via receive interrupts (e.g. 8byte)
What should I do to send it through tx interrupt?

Or
I would like you to tell me how to generate tx interrupts.
Best regards,
Sunny
  • I used the function UART_fIFOConfig_v0 to do UART_FIFO_CONFIG_RXCLR.

    It also seems to have solved this problem by reactivating UART_INT_THR through UART_intEnable_v0.
    void uartIsr()
    {
        static uint32_t txStrLength = sizeof(txArray);
        static uint32_t count       = 0;
        uint32_t        intId       = 0;
        rxByte      = 0;
    
        intId = UART_intIdentityGet_v0(CSL_UART_2_REGS);
        switch(intId)
        {
            case UART_INTID_TX_THRES_REACH:
                if( 0 != txStrLength)
                {
                    UART_charPut_v0(CSL_UART_2_REGS, txArray[count]);
                    txStrLength--;
                    count++;
                }
                else
                {
                    txStrLength = 0;
                    count = 0;
                    UART_intDisable_v0(CSL_UART_2_REGS, UART_INT_THR );
                }
    
                break;
    
            case UART_INTID_RX_THRES_REACH:
    //            rxByte = UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
    //            UART_charPut_v0(CSL_UART_2_REGS, rxByte);
                txArray[txStrLength++] =  UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
                UART_charPut_v0(CSL_UART_2_REGS, txArray[txStrLength-1]);
                if(txStrLength == 8)
                {
                    UART_fIFOConfig_v0(CSL_UART_2_REGS, UART_FIFO_CONFIG_RXCLR);
                    UART_intEnable_v0(CSL_UART_2_REGS, UART_INT_THR );
                }
                break;
    
            case UART_INTID_RX_LINE_STAT_ERROR:
            case UART_INTID_CHAR_TIMEOUT:
                UART_charGetNonBlocking_v0(CSL_UART_2_REGS);
                break;
    
            default:
                break;
    
        }
    }