S32K312 DMA+IDLE+UART

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32K312 DMA+IDLE+UART

1,465 次查看
guoweifeng
Contributor I

Hello, I encountered some issues while trying to receive using DMA+IDLE+UART.

 

At present, it is determined whether to receive by polling the IDLE status bit, but there are problems .For example, when the received length is too long, it is necessary to wait for time to determine the IDLE bit, so that DMA can transfer all the data and assign the remaining length value.

 

So I have the following question:

1.UART does not enter the configured UART RX callback function after configuring DMA reception. Unless it is done through DMA's rx callback. Is there a problem with my configuration?

2. I noticed that DMA interrupts need to be fully buffered or at least half buffered before entering the ISR function. Is there any other way to enter DMA ISR?

标记 (1)
0 项奖励
回复
1 回复

1,433 次查看
RomanVR
NXP Employee
NXP Employee

Hi @guoweifeng

When configuring UART to use DMA for faster data transfer, you have to configure 2 DMA channels: one for receiving and one for transmitting data. This eliminates the need for UART callback function to differentiate between receive and transmit event. Although, if you configure a callback function for UART, while also configure DMA, the callback will always be triggered by the DMA interrupt, as it is the DMA that handles the data transfer.


DMA interrupts are generated based on the number of bytes you specify for the data transfer. For better explanation, here is how DMA handles buffers with UART:

  • Buffer Configuration: A memory buffer is assigned to store the data to be transmitted/received. This buffer is typically a contiguous area of memory.
  • DMA Request (TX): Once the UART is configured and enabled, the DMA is set up to transfer data from the buffer to the UART for transmission. The DMA will move the data from memory directly to the UART transmission line (TX) without the need for the CPU to manage each byte of data.
  • DMA Request (RX): When the UART receives data, it generates an interrupt that triggers the DMA to move the data from the UART to system memory.
  • Transfer Process: The DMA begins transferring data from the memory buffer to the UART. The UART sends each byte via the transmission line in the appropriate format (e.g., 8 data bits, 1 stop bit, etc.).
  • Transfer Completion: Once all data has been transmitted, the DMA notifies the CPU (e.g., via an interrupt) to take any further actions if needed, such as preparing a new set of data for transmission.

- RomanVR.

Best Regards!
0 项奖励
回复