problem at EDMA with 2 UART in Kinetis KV24F64

cancel
Showing results for 
Search instead for 
Did you mean: 

problem at EDMA with 2 UART in Kinetis KV24F64

73 Views
amerzater
Contributor III

Hello Dears.

when implementing two UART (UART0 , UART1) with RX EDMA on UART0 and TX EDMA on UART1 , I am losing Rx Packets on UART0 RX EDMA link when sending Data throught the EDMA link on UART1

 

UART0 EDMA init code:

 

Spoiler

UART_GetDefaultConfig(&uartConfig);
uartConfig.baudRate_Bps = 1000000;
uartConfig.enableTx = false;
uartConfig.enableRx = true;
uartConfig.stopBitCount=kUART_OneStopBit;

statusSt= UART_Init(UART1, &uartConfig, UART1_CLK_FREQ);
/* Init DMAMUX */
DMAMUX_Init(UART1_DMAMUX_BASEADDR);
/* Set channel for UART */

DMAMUX_SetSource(UART1_DMAMUX_BASEADDR, UART_RX_DMA_CHANNEL, UART_RX_DMA_REQUEST);

DMAMUX_EnableChannel(UART1_DMAMUX_BASEADDR, UART_RX_DMA_CHANNEL);

/* Init the EDMA module */
EDMA_GetDefaultConfig(&config);
config.enableRoundRobinArbitration=true;
EDMA_Init(UART1_DMA_BASEADDR, &config);

EDMA_CreateHandle(&g_uartRxEdmaHandle, UART1_DMA_BASEADDR, UART_RX_DMA_CHANNEL);

edma_transfer_config_t xferConfig;

/* Install TCD memory. */
EDMA_InstallTCDMemory(&g_uartRxEdmaHandle, tcdMemoryPoolPtr, 1);

/* Prepare transfer to receive data to ring buffer. */
EDMA_PrepareTransfer(&xferConfig, (void *)UART_GetDataRegisterAddress(UART1), sizeof(uint8_t), g_ringBuffer,
sizeof(uint8_t), sizeof(uint8_t), UART1_BUFFER_LENGTH, kEDMA_PeripheralToMemory);

/* Submit transfer. */
g_uartRxEdmaHandle.tcdUsed = 1U;
g_uartRxEdmaHandle.tail = 0U;
EDMA_TcdReset(&g_uartRxEdmaHandle.tcdPool[0U]);
EDMA_TcdSetTransferConfig(&g_uartRxEdmaHandle.tcdPool[0U], &xferConfig, tcdMemoryPoolPtr);

/* Enable major interrupt for calculating the received bytes. */
// g_uartRxEdmaHandle.tcdPool[0U].CSR |= DMA_CSR_INTMAJOR_MASK;

/* There is no live chain, TCD block need to be installed in TCD registers. */
EDMA_InstallTCD(UART1_DMA_BASEADDR, UART_RX_DMA_CHANNEL, &g_uartRxEdmaHandle.tcdPool[0U]);

/* Start EDMA transfer. */
EDMA_StartTransfer(&g_uartRxEdmaHandle);

/* Enable UART RX EDMA. */
UART_EnableRxDMA(UART1, true);


UART_EnableInterrupts(UART1, kUART_NoiseErrorInterruptEnable |kUART_FramingErrorInterruptEnable
|kUART_RxOverrunInterruptEnable);

EnableIRQ(UART1_ERR_IRQn);

NVIC_SetPriority(UART1_ERR_IRQn, 0); /* 0 Set priority to interrupt */

 UART1 (MOdBusUART)  EDMA init Fun:

Spoiler

UART_GetDefaultConfig(&MOdBusuartConfig);
MOdBusuartConfig.baudRate_Bps = MOdBusBR;
MOdBusuartConfig.enableTx = true;
MOdBusuartConfig.enableRx = true;
MOdBusuartConfig.idleType = kUART_IdleTypeStopBit;

int myInitResult= UART_Init(MOdBusUART, &MOdBusuartConfig, MOdBusUART_CLK_FREQ);
preem.channelPriority=4;
preem.enableChannelPreemption=1;
preem.enablePreemptAbility=0;
EDMA_SetChannelPreemptionConfig (UART1_DMA_BASEADDR,MOdBusUART_TX_DMA_CHANNEL, &preem);

DMAMUX_SetSource(UART1_DMAMUX_BASEADDR, MOdBusUART_TX_DMA_CHANNEL, MOdBusUART_TX_DMA_REQUEST);

DMAMUX_EnableChannel(UART1_DMAMUX_BASEADDR, MOdBusUART_TX_DMA_CHANNEL);

EDMA_CreateHandle(&g_MOdBusuartTxEdmaHandle,UART1_DMA_BASEADDR, MOdBusUART_TX_DMA_CHANNEL);

MOdBusUART->MODEM=0x06;
UART_ClearStatusFlags(MOdBusUART,
(kUART_IdleLineFlag | kUART_NoiseErrorFlag | kUART_FramingErrorFlag | kUART_ParityErrorFlag| kUART_RxOverrunFlag));

UART_TransferCreateHandleEDMA(MOdBusUART, &g_MOdBusuartEdmaHandle, NULL, NULL, &g_MOdBusuartTxEdmaHandle,
NULL);

UART_EnableInterrupts(MOdBusUART, kUART_NoiseErrorInterruptEnable |kUART_FramingErrorInterruptEnable
|kUART_RxOverrunInterruptEnable |kUART_RxDataRegFullInterruptEnable);
EnableIRQ(UART0_RX_TX_IRQn);
EnableIRQ(UART0_ERR_IRQn);
NVIC_SetPriority(UART0_RX_TX_IRQn, 4); /* 0 Set priority to interrupt */
NVIC_SetPriority(UART0_ERR_IRQn, 4); /* 0 Set priority to interrupt */

 

 I am sure that right at starting UART0 (MOdBusUART) sending sending function

UART_SendEDMA(MOdBusUART, &g_MOdBusuartEdmaHandle , &MOdBusSendXfer);

UART1  Rx EDMA is losing some Rx bytes !!

Labels (1)
Tags (2)
0 Kudos
0 Replies