Hello,
I refer to the Time-Out Counter section of UART and set TIMEOUT_BEHACE to 1, but I didn't read the timeout interrupt in the interrupt function. The code is as follows:
static uint32_t g_linBaseAddr[3] = { CSL_UART6_BASE, \ CSL_UART8_BASE, \ CSL_MCU_UART0_BASE \ }; static uint32_t TISCI_pmUartModule[3] = { TISCI_DEV_UART6,\ TISCI_DEV_UART8,\ TISCI_DEV_MCU_UART0 \ }; static void UART0_IntFxn(uintptr_t arg) { uint32_t intType; //int2status; uint8_t temp; intType = UARTIntIdentityGet(g_linBaseAddr[0]); printf("intType:0x%x\n", intType); if ((intType & UART_INTID_CHAR_TIMEOUT) == UART_INTID_CHAR_TIMEOUT) { intType = UARTIntIdentityGet(g_linBaseAddr[0]); UARTSetTimeOutValue(g_linBaseAddr[0], 0, UART_TIMEOUT_COUNTER_RESET); checkRecvTimeOut(0); } if ((intType & UART_INTID_RX_THRES_REACH) == UART_INTID_RX_THRES_REACH) { temp = UARTCharGet(g_linBaseAddr[0]) & 0xFF; printf("tempByte:0x%x\n", temp); if(temp == 0x00) { g_mTicks = 0; lin_slaveFinsh[0] = 0; lin_rxlength[0] = 0; LIN_ProcessBreakDetect(0, temp); } LIN_ProcessFrame(0, temp); lin_buffer[0][(lin_rxlength[0]++)] = temp; } } static int32_t UART_RegisterInterrupt(uint32_t intNum, void f(uintptr_t)) { int32_t configStatus = STW_SOK; OsalRegisterIntrParams_t intrPrms; OsalInterruptRetCode_e osalRetVal; HwiP_Handle hwiHandle = NULL; /* Enable CPU Interrupts and register ISR - UART Intr0 */ Osal_RegisterInterrupt_initParams(&intrPrms); /* Populate the interrupt parameters */ intrPrms.corepacConfig.arg = (uintptr_t) NULL; intrPrms.corepacConfig.isrRoutine = f; intrPrms.corepacConfig.priority = 1U; intrPrms.corepacConfig.corepacEventNum = 0U; intrPrms.corepacConfig.intVecNum = intNum; /* Register interrupts */ osalRetVal = Osal_RegisterInterrupt(&intrPrms, &hwiHandle); if(OSAL_INT_SUCCESS != osalRetVal) { configStatus = CSL_EFAIL; } return configStatus; } int32_t UART_RegisterInt(uint8_t linchannel) { int32_t configStatus = STW_SOK; // if(registerInitStatus) // return configStatus; int32_t ret; uint32_t intNum; switch(linchannel) { case 0: /* Disable UART interrupts. */ UARTIntDisable(g_linBaseAddr[0], UART_INT_RHR_CTI | UART_INT_THR | UART_INT_LINE_STAT); UARTInt2Disable(g_linBaseAddr[0], UART_INT2_TX_EMPTY | UART_INT2_RX_EMPTY); uartInitCfg[6].baseAddr = g_linBaseAddr[0]; ret = uartInitCfg[6].configSocIntrPath(&uartInitCfg[6], 1); if(ret != UART_SUCCESS) { printf("configSocIntrPath failed.\n"); // return -1; } intNum = uartInitCfg[6].intNum; printf("intNum0:%d\n",intNum); // configStatus = UART_RegisterInterrupt(intNum, &UART_IntFxn); configStatus = UART_RegisterInterrupt(intNum, &UART0_IntFxn); break; default: break; } return configStatus; } static void UART_ConfigInit(uint32_t baseAddr, uint32_t baudRate, uint32_t wordLength, uint32_t stopBit, uint32_t parity, uint32_t mode) { uint32_t divisorValue = 0U, fifoConfig = 0U; uint32_t inputClock = UART_MODULE_INPUT_CLK; #if defined (SOC_AM65XX) || defined (SOC_J721E) || defined (SOC_J7200) || defined (SOC_J721S2) || defined (SOC_J784S4) if (baseAddr == CSL_MCU_UART0_BASE) { inputClock = UART_MODULE_MCU_INPUT_CLK; } #endif /* Performing a module reset. */ UARTModuleReset(baseAddr); /* 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_1, UART_FCR_TX_TRIG_LVL_56, 1, 1, 1, UART_DMA_EN_PATH_SCR, UART_DMA_MODE_0_ENABLE); /* Configuring the FIFO settings. */ UARTFIFOConfig(baseAddr, fifoConfig); /* Performing Baud Rate settings. */ /* Computing the Divisor Value. */ divisorValue = UARTDivisorValCompute(inputClock, baudRate, mode, UART_MIR_OVERSAMPLING_RATE_42); /* Programming the Divisor Latches. */ UARTDivisorLatchWrite(baseAddr, divisorValue); /* Switching to Configuration Mode B. */ UARTRegConfigModeEnable(baseAddr, UART_REG_CONFIG_MODE_B); /* Programming the Line Characteristics. */ UARTLineCharacConfig(baseAddr, (wordLength | stopBit), parity); /* Disabling write access to Divisor Latches. */ UARTDivisorLatchDisable(baseAddr); /* Disabling Break Control. */ UARTBreakCtl(baseAddr, UART_BREAK_COND_DISABLE); // uart_setTimeOut(baseAddr, UART_TIMEOUT_BEHAVE_ENABLE); /* Uart enable */ UARTOperatingModeSelect(baseAddr, mode); } static void uartConfig_prcmEnable(uint8_t uartchannel, uint32_t baudRate) { int32_t status; #if 0 Board_initCfg boardCfg; Board_STATUS boardStatus; boardCfg = BOARD_INIT_PINMUX_CONFIG | BOARD_INIT_UART_STDIO; boardStatus = Board_init(boardCfg); if (boardStatus != BOARD_SOK) { printf("[Error] Board init failed!!\n"); } else { printf("[OK] Board init successed!!\n"); } #endif // UART_HwAttrs uart_cfg; // int32_t ret; // uint32_t intNum; /* Disable the UART interrupt */ // UART_socGetInitCfg(0, &uart_cfg); // uartInitCfg[0].baseAddr = g_linBaseAddr[uartchannel]; // printf("intNum1:%d address:%x\n",uartInitCfg[0].intNum, uartInitCfg[0].baseAddr); // ret = uartInitCfg[0].configSocIntrPath(&uartInitCfg[0], 1); // if(ret != UART_SUCCESS) // { // printf("configSocIntrPath failed----\n"); // } // intNum = uartInitCfg[0].intNum; // printf("intNum2:%d\n",intNum); /* Set the UART Parameters */ UART_ConfigInit(g_linBaseAddr[uartchannel], baudRate, WORD_LENGTH, STOP_BIT, PARITY, UART_MODE); uintptr_t key = UART_osalHardwareIntDisable(); UART_osalHardwareIntRestore(key); status = UART_RegisterInt(uartchannel); if(STW_SOK != status) { printf("CrossBar/Interrupt Configuration failed.\n"); } else { // registerInitStatus = 1; isUartEnable[uartchannel] = 1; printf("CrossBar/Interrupt Configuration done.\n"); } UARTIntEnable(g_linBaseAddr[uartchannel], UART_INT_RHR_CTI); UARTSetTimeOutValue(baseAddr, 0, UART_TIMEOUT_COUNTER_NO_CHANGE); // lin_fifo_init(); printf("[Debug] UARTConfigInit successed!!!\n"); } void uart_test_app(uint8_t uartchannel) { // char dataBuffer[100]; uartBaseAddr = g_linBaseAddr[uartchannel]; int32_t status = Sciclient_pmSetModuleState(TISCI_pmUartModule[uartchannel], TISCI_MSG_VALUE_DEVICE_SW_STATE_ON, TISCI_MSG_FLAG_AOP, SCICLIENT_SERVICE_WAIT_FOREVER); if (status == 0) { printf("local_moduleClockEnable OK\n"); } else { printf("local_moduleClockEnable failed!!!!!!\n"); } /*uart configuration and PRCM enable*/ uartConfig_prcmEnable(uartchannel, BAUD_RATE); uint8_t count = 8; while(count--) { UARTConfigPutc(uartBaseAddr, '*'); } UARTConfigPutc(uartBaseAddr, '\n'); printf("\nCSL_UART0_BASE send * OK---\n"); } int main(void) { uart_test_app(0); }
The following figure shows the debug log. The interrupt flag is obtained from UartinTitid_Rx_thres_REACH. Only UART_INTID_RX_THRES_REACH is detected, and UART_INTID_CHAR_TIMEOUT is not detected.