Hello,
I am trying to get UART running with EDMA on an MIMXRT1010. The problem I have is that once a "Receive Data Register Full" interrupt is triggered, the interrupt "gets stuck" and the interrupt handler is executed in a loop, even though nothing is being received anymore. Clearing the interrupt and status flags does not help.
This is what my interrupt handler looks like:
void LPUART1_IRQHandler(void) {
log_info("IRQ: Status flags 0x%08X, FIFO flags 0x%08X", LPUART1->STAT, LPUART1->FIFO);
if (LPUART_GetStatusFlags(LPUART1) & kLPUART_RxDataRegFullFlag) {
uint8_t data = LPUART_ReadByte(LPUART1);
log_info("UART RX: %02X", data);
}
NVIC_ClearPendingIRQ(LPUART1_IRQn); // This does not help
SDK_ISR_EXIT_BARRIER;
}
With that I get the following in the logs:
IRQ: Status flags 0x01E2C000, FIFO flags 0x00800099
UART RX: 00
IRQ: Status flags 0x01C2C000, FIFO flags 0x00C00099
IRQ: Status flags 0x01C2C000, FIFO flags 0x00C00099
... (continues)
This is basically starving my application since the only thing that's running anymore is this interrupt handler. What am I doing wrong?
This is the UART initialization code:
#define BLUETOOTH_UART_RX_IOMUX IOMUXC_GPIO_09_LPUART1_RXD
#define BLUETOOTH_UART_TX_IOMUX IOMUXC_GPIO_10_LPUART1_TXD
#define BLUETOOTH_UART_PORT LPUART1
#define BLUETOOTH_UART_IRQn LPUART1_IRQn
#define BLUETOOTH_UART_BAUDRATE 115200u
#define LPUART_TX_DMA_CHANNEL 0u
#define LPUART_TX_DMA_REQUEST kDmaRequestMuxLPUART1Tx
#define BT_LPUART_DMAMUX_BASEADDR DMAMUX
#define BT_LPUART_DMA_BASEADDR DMA0
void board_hal_uart_init(const board_hal_uart_config_t *p_config) {
APP_ASSERT(p_config != NULL, "Invalid UART configuration");
APP_ASSERT(p_config->rx_isr_handler != NULL, "Invalid UART RX ISR handler");
APP_ASSERT(p_config->tx_done_callback != NULL, "Invalid UART TX done callback");
m_bluetooth_uart.p_config = p_config;
IOMUXC_SetPinMux(BLUETOOTH_UART_RX_IOMUX, 0u);
IOMUXC_SetPinMux(BLUETOOTH_UART_TX_IOMUX, 0u);
IOMUXC_SetPinConfig(BLUETOOTH_UART_RX_IOMUX, GPIO_SLEW_RATE_CONFIG(GPIO_SLEW_RATE_SLOW) |
GPIO_DRIVE_STRENGTH_CONFIG(GPIO_DRIVE_STRENGTH_R04) |
GPIO_SPEED_CONFIG(GPIO_SPEED_FAST_150MHz) |
GPIO_OPEN_DRAIN_CONFIG(GPIO_OPEN_DRAIN_ENABLED) |
GPIO_PULLKEEP_CONFIG(GPIO_PULLKEEP_DISABLED) |
GPIO_PULLKEEP_SELECT_CONFIG(GPIO_PULLKEEP_SELECT_KEEPER) |
GPIO_PULL_CONFIG(GPIO_PULL_PU_22KOhm) |
GPIO_HYSTERESIS_CONFIG(GPIO_HYSTERESIS_DISABLED));
IOMUXC_SetPinConfig(BLUETOOTH_UART_TX_IOMUX, GPIO_SLEW_RATE_CONFIG(GPIO_SLEW_RATE_SLOW) |
GPIO_DRIVE_STRENGTH_CONFIG(GPIO_DRIVE_STRENGTH_R04) |
GPIO_SPEED_CONFIG(GPIO_SPEED_FAST_150MHz) |
GPIO_OPEN_DRAIN_CONFIG(GPIO_OPEN_DRAIN_ENABLED) |
GPIO_PULLKEEP_CONFIG(GPIO_PULLKEEP_DISABLED) |
GPIO_PULLKEEP_SELECT_CONFIG(GPIO_PULLKEEP_SELECT_KEEPER) |
GPIO_PULL_CONFIG(GPIO_PULL_PU_22KOhm) |
GPIO_HYSTERESIS_CONFIG(GPIO_HYSTERESIS_DISABLED));
lpuart_config_t uart_config;
LPUART_GetDefaultConfig(&uart_config);
uart_config.baudRate_Bps = BLUETOOTH_UART_BAUDRATE;
uart_config.enableRx = true;
uart_config.enableTx = true;
status_t status = LPUART_Init(BLUETOOTH_UART_PORT, &uart_config, board_hal_uart_get_frequency());
APP_ASSERT(status == kStatus_Success, "Failed to initialize UART");
LPUART_EnableInterrupts(BLUETOOTH_UART_PORT, kLPUART_RxDataRegFullInterruptEnable);
NVIC_SetPriority(LPUART1_IRQn, BLUETOOTH_UART_INTERRUPT_PRIORITY);
EnableIRQ(BLUETOOTH_UART_IRQn);
#if defined(FSL_FEATURE_SOC_DMAMUX_COUNT) && FSL_FEATURE_SOC_DMAMUX_COUNT
DMAMUX_Init(BT_LPUART_DMAMUX_BASEADDR);
DMAMUX_SetSource(BT_LPUART_DMAMUX_BASEADDR, LPUART_TX_DMA_CHANNEL, LPUART_TX_DMA_REQUEST);
DMAMUX_EnableChannel(BT_LPUART_DMAMUX_BASEADDR, LPUART_TX_DMA_CHANNEL);
#endif
// Initialize the EDMA module
edma_config_t dma_config;
EDMA_GetDefaultConfig(&dma_config);
EDMA_Init(BT_LPUART_DMA_BASEADDR, &dma_config);
EDMA_CreateHandle(&m_bluetooth_uart.edma_handle, BT_LPUART_DMA_BASEADDR, LPUART_TX_DMA_CHANNEL);
#if defined(FSL_FEATURE_EDMA_HAS_CHANNEL_MUX) && FSL_FEATURE_EDMA_HAS_CHANNEL_MUX
EDMA_SetChannelMux(EXAMPLE_LPUART_DMA_BASEADDR, LPUART_TX_DMA_CHANNEL, DEMO_LPUART_TX_EDMA_CHANNEL);
#endif
// Create LPUART DMA handle
LPUART_TransferCreateHandleEDMA(BLUETOOTH_UART_PORT,
&m_bluetooth_uart.lpuart_edma_handle,
lpuart_edma_transfer_callback,
NULL,
&m_bluetooth_uart.edma_handle,
NULL);
log_info("UART initialized");
}
Any help with this issue will be appreciated. Thank you.
Solved! Go to Solution.