I am working on UART DMA function and the UART2 baud rate is set as 115200. PC also set baud rate as 115200,
Both send and receive is correct. However, one of them set different baud rate, for example, MK64F512 device sets 115200 and PC sets as 57600. I send a data from PC to device, the MK64F512 device could not receive any data from PC.
I try to re-call DMA function, re-enable UART2 DMS interrupt, ..... UART2 DMA could not receive any data.
The GetRemaining code is zero after PC sends once data to device with wrong baud rate and the GetRing code as below,
How can I fix the issue?
byteCount = GetRingBufferLengthEDMA_UART0();
uint32_t regPrimask = 0U;
uint32_t receivedBytes = 0U;
/* Disable IRQ, protect ring buffer. */
regPrimask = DisableGlobalIRQ();
UART_RING_BUFFER_SIZE - EDMA_GetRemainingMajorLoopCount(UART0_RX_DMA_BASEADDR, UART0_RX_DMA_CHANNEL);
/* If the received bytes is less than index value, it means the ring buffer has reached it boundary. */
if (receivedBytes < uart0_ringBufferIndex)
receivedBytes += UART_RING_BUFFER_SIZE;
receivedBytes -= uart0_ringBufferIndex;
/* Enable IRQ if previously enabled. */