S32K344 UART DMA

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K344 UART DMA

Jump to solution
3,609 Views
Neo1096
Contributor III

I used S32K312 RTD4.0.0. I referred to several examples in the forum, but encountered several problems when the code ran

1. Define whether uint8_t Rx_Buffer[MSG_LEN] needs to be written as __attribute__((aligned(32))) uint8_t Rx_Buffer[MSG_LEN] __attribute__((section. (".mcal_bss_no_cacheable"))); Why?

2. After the program runs, it will get stuck here, with the status always being busy and not running further. Uart_TransmitStatus = Lpuart_Uart_Ip_GetTransmitStatus(transChannel, &T_bytesRemaining);

3. I don't understand the difference between using DMA and the interrupt method. Is it because DMA reduces the number of times entering interrupts? When will DMA trigger an interrupt for me to read the group, or can I read the group by query? How can I know which address of the storage array should be found in this query by query?

Neo1096_0-1750145351561.png

 

0 Kudos
Reply
1 Solution
3,538 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Neo1096

I can't help you check your code, and I can't modify it either, it's too messy. I

made a current version of the routine for your reference.

The function implemented by this routine is to forward the received data. You can test it and refer to it.

View solution in original post

0 Kudos
Reply
10 Replies
3,539 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Neo1096

I can't help you check your code, and I can't modify it either, it's too messy. I

made a current version of the routine for your reference.

The function implemented by this routine is to forward the received data. You can test it and refer to it.

0 Kudos
Reply
3,299 Views
Neo1096
Contributor III

Hello, I have a new question.

Currently, I need to receive a high-speed (with a baud rate of 230400) data stream without idle interrupts and without frame format. I hope to read the data stored in the DMA cache at regular intervals (for example, 100us). How can I achieve this using DMA?

Can DMA be configured with a circular buffer?

0 Kudos
Reply
3,528 Views
Neo1096
Contributor III

Sorry, there were codes for other functions in the code I uploaded before

 

I'm using the RTD4.0 library. The demo you uploaded seems to be 1.0. The configuration seems to be different. For example, when configuring the DMA logic channle of DMA in RTD4.0, there is no option to Enable DMAMUX Source. Is there a routine of UART-DMA without MCAL for the RTD4.0 library?

 

My current problem is that it has always been in a busy state when Lpuart_Uart_Ip_GetReceiveStatus occurs, so I have been in this loop and cannot jump out.

Neo1096_0-1750312399043.png

 

0 Kudos
Reply
3,498 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Neo1096

I'm not sure how you tested it, here is a screenshot of my test, is there any problem?

Senlent_0-1750327640606.png

 

0 Kudos
Reply
3,466 Views
Neo1096
Contributor III

My previous test was to short-circuit the TX and RX of the chip

If I use the serial port assistant, the problem I had before won't occur

0 Kudos
Reply
3,524 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Neo1096

This example is based on RTD 4.0.0, LLD, the same version you are using now.

0 Kudos
Reply
3,513 Views
Neo1096
Contributor III

Thank you very much. I understand. The code works now, but there are still two questions that I don't understand

In the main function, using "Lpuart_Uart_Ip_SyncSend" can interrupt, but it cannot receive data correctly. If it is changed to "Lpuart_Uart_Ip_AsyncSend", it can still run. What might be the reason?

2. What was sent was "Hello, This message is sent via Uart!" \r\n, but there will be one less /n when receiving. If I change the code to Lpuart_Uart_Ip_AsyncSend(0, WELCOME_MSG, strlen(WELCOME_MSG)+1); Then /n can be received. What could be the reason

Neo1096_0-1750319682105.png

Neo1096_1-1750319768853.png

 

 

0 Kudos
Reply
3,566 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Neo1096

1.When you use DMA, the data it used must be placed in the non-cache area

2.I need to spend some time to install the version you use, or I can find a demo for your reference.

3.DMA and interrupts are selected according to the actual usage scenario. I can't simply reply to you whether there is any difference in the number of interrupts. For example, for large segments of data that need to be transmitted, DMA is undoubtedly a very good choice, which can reduce the dependence on the CPU. When you use DMA, whether for receiving or sending, you must of course set the source address and destination address you want to transmit first. These addresses are where you store data.

0 Kudos
Reply
3,548 Views
Neo1096
Contributor III

I hope to achieve data reception through dma and be able to generate overflow interrupts. Obtain the data length in the idle interrupt and switch the buffer array to read the data within 1ms.

 

In the sample code, the code for whether to use DMA to receive the receiving part of uart seems similar. Neither is the idle interrupt switching buffer of uart used, nor is the receiving array interval of DMA configured. It seems that all are handled by the library code of uart, including the callback function UART_event_cbk in the sample code.

0 Kudos
Reply
3,549 Views
Neo1096
Contributor III

Please help verify the problems encountered in the code I uploaded. Thank you

0 Kudos
Reply