I am using S32K146 and using UART TX and RX with DMA. Its working fine most of time but sometime unable to tx as lpuart0_state.isTxBusy doesn't reset to false. As this is rarely occurring, I am unable to reproduce it for debugging. Below are the configuration for UART. Please let me know how to debug it.
void init_uart(void){
status_t ret = STATUS_SUCCESS;
lpuart_user_config_t lpuart1_cfg;
edma_init_iot_comm();
lpuart1_cfg.transferType = LPUART_USING_DMA;
lpuart1_cfg.baudRate = 1000000;
lpuart1_cfg.parityMode = LPUART_PARITY_DISABLED;
lpuart1_cfg.stopBitCount = LPUART_ONE_STOP_BIT;
lpuart1_cfg.bitCountPerChar = LPUART_8_BITS_PER_CHAR;
lpuart1_cfg.rxDMAChannel = EDMA_CHN1_NUMBER;
lpuart1_cfg.txDMAChannel = EDMA_CHN0_NUMBER;
ret = LPUART_DRV_Init(UART_COM_4G, &lpuart0_state, &lpuart1_cfg);
DEV_ASSERT(ret == STATUS_SUCCESS);
// setLpuartHardFlowCtrl();
LPUART_DRV_InstallTxCallback(UART_COM_4G, lpuart_tx_callback_t, NULL);
LPUART_DRV_InstallRxCallback(UART_COM_4G, lpuart_rx_callback_t, NULL);
LPUART_DRV_ReceiveData(UART_COM_4G, iot_rx_struct.data, MAX_RX_IOT_COMM_BUFFER);
IOT_COMM_UART_FLOW_START_RX;
}
static status_t edma_init_iot_comm(void){
status_t ret = STATUS_SUCCESS;
edma_chn_state_t *const edma_channel_states[] = {
&dma_ctrl_chn0_state,
&dma_ctrl_chn1_state
};
edma_channel_config_t dm_chn0_cfg = {
.channelPriority = EDMA_CHN_PRIORITY_1,
.virtChnConfig = EDMA_CHN0_NUMBER,
.source = EDMA_REQ_LPUART0_TX,
.callback = NULL,
.callbackParam = NULL,
.enableTrigger = false
};
edma_channel_config_t dm_chn1_cfg = {
.channelPriority = EDMA_CHN_PRIORITY_0,
.virtChnConfig = EDMA_CHN1_NUMBER,
.source = EDMA_REQ_LPUART0_RX,
.callback = edma_RX_callback, //NULL,
.callbackParam = NULL,
.enableTrigger = false
};
const edma_channel_config_t *const edma_chn_cfg_arr[] = {
&dm_chn0_cfg,
&dm_chn1_cfg
};
edma_user_config_t dma_ctrl_init_cfg = {
.chnArbitration = EDMA_ARBITRATION_FIXED_PRIORITY,
.haltOnError = false
};
ret = EDMA_DRV_Init(&dma_ctrl_state, &dma_ctrl_init_cfg, edma_channel_states, edma_chn_cfg_arr, EDMA_CONFIGURED_CHANNELS_COUNT);
DEV_ASSERT(ret == STATUS_SUCCESS);
return ret;
}
Hi,
hard to suggest here. I can give few hints only...
- be sure latest SDK version is used
- try to lower baudrate if possible and check, if issue appears too
- change DMA priorities over channels used
- when TXbusy is not reset, check within debugger internal state of lpuart driver and respective DMA channel (driver variable and module registers). Compare values with data sent, if any.
BR, Petr
hI, I tried but still unable to find the issue. any other suggestion on debugging it ?
Attaching resisters value during the issue
LPUART_0:
DMA: