Tool/software: Code Composer Studio
Hi, all:
I use "PROCESSOR_SDK_VISION_03_06_00_00/ti_components/drivers/pdk_01_10_02_07/packages/ti/csl/example/uart/uart_intr" demo to configure TDA2XX`s UART3.
I use interrupt mode to configure UART3. Put simply, I found my code can not clear UART3`s interrupt flag. My interrupt response function running over and over again.
Void McUartLink_drvSetDrvCfg()
{
uint32_t uartBaseAddr;
UInt32 cookie = 0;
uint32_t intId = 0;
Vps_printf("Interrupt 0");
uartBaseAddr = 0x48020000U;//SOC_UART3_BASE;
Vps_printf("Interrupt 1");
// padConfig_prcmEnable();
PlatformUnlockMMR();
Bsp_platformSetPinmuxRegs(CTRL_CORE_PAD_UART3_RXD_UART3_RXD_MUXMODE_UART3_RXD_0,
CTRL_CORE_PAD_UART3_RXD,
BSP_PLATFORM_IOPAD_CFG_DEFAULT);
Bsp_platformSetPinmuxRegs(CTRL_CORE_PAD_UART3_TXD_UART3_TXD_MUXMODE_UART3_TXD_0,
CTRL_CORE_PAD_UART3_TXD,
BSP_PLATFORM_IOPAD_CFG_DEFAULT);
Vps_printf("Xbar uart intr Id !!!\n");
IntXbar_connectIRQ(UART3_IPU_IRQ_NUM, UART3_GLOBAL_IRQ);
/* Disabling the global interrupts */
cookie = Hwi_disable();
Vps_printf("Register call back function !!!\n");
gMcUartLink_obj.uart3Rxhwi = BspOsal_registerIntr(UART3_IPU_IRQ_NUM,
(BspOsal_IntrFuncPtr)UART3RxIsrCallback,
&gMcUartLink_obj
);
if( gMcUartLink_obj.uart3Rxhwi == NULL)
{
Vps_printf(" UTILS: DCAN INTERRUPT: HWI Create Failed !!!\n");
// UTILS_assert(0);
}
/* Performing a module reset. */
UARTModuleReset(uartBaseAddr);
/* Performing FIFO configurations. */
UartFIFOConfigure(uartBaseAddr);
/* Performing Baud Rate settings. */
UartBaudRateSet(uartBaseAddr);
/* Switching to Configuration Mode B. */
UARTRegConfigModeEnable(uartBaseAddr, UART_REG_CONFIG_MODE_B);
/* Programming the Line Characteristics. */
UARTLineCharacConfig(uartBaseAddr,
(UART_FRAME_WORD_LENGTH_8 | UART_FRAME_NUM_STB_1),
UART_PARITY_NONE);
/* Disabling write access to Divisor Latches. */
UARTDivisorLatchDisable(uartBaseAddr);
/* Disabling Break Control. */
UARTBreakCtl(uartBaseAddr, UART_BREAK_COND_DISABLE);
/* Switching to UART16x operating mode. */
UARTOperatingModeSelect(uartBaseAddr, UART16x_OPER_MODE);
//Print return value of UARTIntIdentityGet(),who will read "UART_IIR" register.
intId = UARTIntIdentityGet(UART3_BASE_ADDR);
Vps_printf("1\tintId is 0x%x\n", intId);
//Print return value of UARTIntIdentityGet(),who will read "UART_IIR" register.
intId = UARTIntIdentityGet(UART3_BASE_ADDR);
Vps_printf("2\tintId is 0x%x\n", intId);
UARTIntEnable(uartBaseAddr, (UART_INT_LINE_STAT | UART_INT_THR |
UART_INT_RHR_CTI));
//Print return value of UARTIntIdentityGet(),who will read "UART_IIR" register.
intId = UARTIntIdentityGet(UART3_BASE_ADDR);
Vps_printf("3\tintId is 0x%x\n", intId);
//Print return value of UARTIntIdentityGet(),who will read "UART_IIR" register.
intId = UARTIntIdentityGet(UART3_BASE_ADDR);
Vps_printf("4\tintId is 0x%x\n", intId);
/* Enable the mcspi2 interrupt */
Hwi_enableInterrupt(UART3_IPU_IRQ_NUM);
/* Restore interrupts */
Hwi_restore(cookie);
}
uint32_t UARTIntIdentityGet(uint32_t baseAddr)
{
uint32_t lcrRegValue = 0;
uint32_t retVal = 0;
/* Switching to Register Operational Mode of operation. */
lcrRegValue = UARTRegConfigModeEnable(baseAddr, UART_REG_OPERATIONAL_MODE);
//Read UART_IIR register
retVal = HW_RD_REG32(baseAddr + UART_IIR) & UART_IIR_IT_TYPE_MASK;
/* Restoring the value of LCR. */
HW_WR_REG32(baseAddr + UART_LCR, lcrRegValue);
return retVal;
}
The code above printf is :
1 intId is 0
2 intId is 0
3 intId is 6
4 intId is 6
I found <<Technical Reference Manual>> says "For the XOFF interrupt, if an XOFF flow character detection caused the interrupt, the interrupt is cleared by an XON flow character detection. If special character detection caused the interrupt, the interrupt is cleared by a read of the UARTi.UART_IIR register." But why I use "UARTIntIdentityGet(UART3_BASE_ADDR);" to read UART_IIR register and the interrupt is not cleared. I heard that if interrupt flag is not clean the system will enter into interrupt over and over again. Because interrupt is all ways open.
The problem troubled me and prevented me from continuing my work. Please help me solve this problem and see if there are any ideas.
Regards.