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.

TDA2SX: UART2

Part Number: TDA2SX

Hi,

in A15 of Tda2sx, i using the uart, uart2 may interrupts in transmit,but can't receive, the following code.

int32_t UARTx_Init(UART_INST_t uartInstance)

{
    int32_t retVal = STW_SOK;
    uint32_t uartx_BAUD_RATE;
    uint32_t uartx_OPER_MODE;
    uint32_t uartx_UART_PARITY_NONE;
    uint32_t uartx_UART_FRAME_WORD_LENGTH_8;
    uint32_t uartx_UART_LCR_NB_STOP_1BIT;
   
    Vps_printf("tm: UART%u Init.\n", uartInstance + 1);
    /* Configure PRCM for UART instance */
    retVal = UtilsUARTxPrcm(uartInstance);
    if (STW_SOK != retVal)
    {
        LibAbortBoot();
    }
   
    /* Configure Pin Mux for UART instance */
    switch (uartInstance)
    {
    case UART2_INST:
        UART2SetPinMux();
        uartx_BAUD_RATE = BAUD_RATE;
        uartx_OPER_MODE = UART13x_OPER_MODE;
        uartx_UART_PARITY_NONE = UART_PARITY_NONE;
        uartx_UART_FRAME_WORD_LENGTH_8 = UART_FRAME_WORD_LENGTH_8;
        uartx_UART_LCR_NB_STOP_1BIT = UART_LCR_NB_STOP_1BIT;
        break;
    case UART3_INST:
        UART3SetPinMux();
        uartx_BAUD_RATE = BAUD_RATE;
        uartx_OPER_MODE = UART13x_OPER_MODE;
        uartx_UART_PARITY_NONE = UART_PARITY_NONE;
        uartx_UART_FRAME_WORD_LENGTH_8 = UART_FRAME_WORD_LENGTH_8;
        uartx_UART_LCR_NB_STOP_1BIT = UART_LCR_NB_STOP_1BIT;
        break;
    default:
        break;
    }

    /* Initialize UART Peripheral */
    retVal = UARTxParam(uartInstance,
            (uint32_t) uartx_BAUD_RATE,
            (uint32_t) uartx_OPER_MODE,
            (uint32_t) uartx_UART_PARITY_NONE,
            (uint32_t) uartx_UART_FRAME_WORD_LENGTH_8,
            (uint32_t) uartx_UART_LCR_NB_STOP_1BIT);    
           
    return retVal;
}
int32_t UARTxParam(UART_INST_t uartInstance,
                    uint32_t    baudRate,
                    uint32_t    operMode,
                    uint32_t    parity,
                    uint32_t    wordLen,
                    uint32_t    stopBit)

{
    uint32_t uart_base_address;
    uint32_t divisorValue = 0, fifoConfig = 0;
    int32_t retVal       = STW_SOK;

    Vps_printf("tm: UART%u_Init Intr Param cfg.\n", uartInstance + 1);

    switch (uartInstance)
    {
        case UART2_INST:
            uart_base_address = SOC_UART2_BASE;
            break;
        case UART3_INST:
            uart_base_address = SOC_UART3_BASE;
            break;
        default:
            retVal = STW_EFAIL;
            break;
    }

    if (retVal == STW_SOK)
    {
        /* Performing a module reset. */
        UARTModuleReset(uart_base_address);

        /* Performing FIFO configurations. */
        /*
        ** - Transmit Trigger Level Granularity is 4
        ** - Receiver Trigger Level Granularity is 1
        ** - Transmit FIFO Space Setting is 56. Hence TX Trigger level
        **   is 8 (64 - 56). The TX FIFO size is 64 bytes.
        ** - The Receiver Trigger Level is 1.
        ** - Clear the Transmit FIFO.
        ** - Clear the Receiver FIFO.
        ** - DMA Mode enabling shall happen through SCR register.
        ** - DMA Mode 0 is enabled. DMA Mode 0 corresponds to No
        **   DMA Mode. Effectively DMA Mode is disabled.
        */
        fifoConfig = UART_FIFO_CONFIG(UART_TRIG_LVL_GRANULARITY_4,
                                      UART_TRIG_LVL_GRANULARITY_4,
                                      UART_FCR_TX_TRIG_LVL_56,
                                      UART_FCR_RX_TRIG_LVL_16,
                                      1U,
                                      1U,
                                      UART_DMA_EN_PATH_SCR,
                                      UART_DMA_MODE_0_ENABLE);

        /* Configuring the FIFO settings. */
        UARTFIFOConfig(uart_base_address, fifoConfig);

        /* Performing Baud Rate settings. */
        /* Computing the Divisor Value. */
        divisorValue = UARTDivisorValCompute(UART_MODULE_INPUT_CLK,
                                             baudRate,
                                             operMode,
                                             UART_MIR_OVERSAMPLING_RATE_42);
        /* Programming the Divisor Latches. */
        UARTDivisorLatchWrite(uart_base_address, divisorValue);

        /* Switching to Configuration Mode B. */
        UARTRegConfigModeEnable(uart_base_address, UART_REG_CONFIG_MODE_B);

        /* Programming the Line Characteristics. */
        UARTLineCharacConfig(uart_base_address,
                             (wordLen | stopBit),
                             parity);

        /* Disabling write access to Divisor Latches. */
        UARTDivisorLatchDisable(uart_base_address);

        /* Disabling Break Control. */
        UARTBreakCtl(uart_base_address, UART_BREAK_COND_DISABLE);

        /* Uart enable */
        UARTOperatingModeSelect(uart_base_address, operMode);

        /* Performing Interrupt configurations. */
        UartxInterruptEnable(uartInstance);
    }

    return retVal;
}
static void UartxInterruptEnable(UART_INST_t uartInstance)
{
    uint32_t        uart_base_address;

    Vps_printf("tm: UART%u_Init Intr cfg.\n", uartInstance + 1);

    /* Configuring INTC to receive UART interrupts. */
    switch (uartInstance)
    {
        case UART2_INST:
            uart_base_address = SOC_UART2_BASE;
            break;

        case UART3_INST:
            uart_base_address = SOC_UART3_BASE;            
            break;

        default:
            break;
    }

    /* Enabling the specified UART interrupts. */
    UARTIntEnable(uart_base_address, (UART_INT_LINE_STAT | UART_INT_THR | UART_INT_RHR_CTI));
}

Best Regards.