S32K344 UART DMA example

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

S32K344 UART DMA example

Jump to solution
7,237 Views
S3RD4R
Contributor I

 

Hello all,

I am using S32K3X4EVB-Q172 development board. I have succesfully implemented interrupt based UART receive however I want to use DMA but i could not find any example. Is there any example of using DMA with UART? 

I am using latest MCAL SDK.

Best regards,

 

 

0 Kudos
Reply
1 Solution
7,171 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

this could be caused by cache. Try to either invalidate the address for the cache of the send buffer or place the buffer in a noncacheable memory.

#pragma GCC section bss ".mcal_bss_no_cacheable"
uint8_t tx_data[15];
#pragma GCC section bss

 

BR, Petr

View solution in original post

0 Kudos
Reply
5 Replies
6,964 Views
WellsonGuo
Contributor II

Hello NXP TechSupport,
may I ask another question?

According to this example,
there is only UART1 for receiving and sending data in while loop,

if I add another UART3(interrupt mode) for communicating with this UART1, even if the DMA callback was triggered with event "LPUART_UART_IP_EVENT_END_TRANSFER", my buffer(Rx_Buffer) is still keeping empty, I don't know what's wrong with my procedures.

please help me, thanks~

*This code flow below is fine while interrupt mode.


while(1)
{
    lpuartStatus = Lpuart_Uart_Ip_AsyncReceive(UART_LPUART_INTERNAL_CHANNEL_1, Rx_Buffer, length);
    if (LPUART_UART_IP_STATUS_SUCCESS != lpuartStatus)
    {
        return FALSE;
    }

//Async send would be OVERRUN during 1.8Mbps baud rate

    lpuartStatus = Lpuart_Uart_Ip_SyncSend(UART_LPUART_INTERNAL_CHANNEL_3, Tx_Buffer,length,1000);
    if (LPUART_UART_IP_STATUS_SUCCESS != lpuartStatus)
    {
        return FALSE;
    }

    do
    {
        lpuartStatus = Lpuart_Uart_Ip_GetReceiveStatus(UART_LPUART_INTERNAL_CHANNEL_1, &remainingBytes);
    } while (LPUART_UART_IP_STATUS_BUSY == lpuartStatus && 0 < T_timeout--);
}

 

(updated)

If I change the priority of DMA channel(UART RX) from 0 to 2, I can receive part of some message from UART3, like below attachment.

 

0 Kudos
Reply
7,195 Views
S3RD4R
Contributor I

I have completed UART via DMA however i have an interesting case. When i copy captured data to a local variable or global variable and send it via UART, totally corrupt messages are sent. Below i add my code and UART output for reference. Do you have any idea?

 

0 Kudos
Reply
7,172 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

this could be caused by cache. Try to either invalidate the address for the cache of the send buffer or place the buffer in a noncacheable memory.

#pragma GCC section bss ".mcal_bss_no_cacheable"
uint8_t tx_data[15];
#pragma GCC section bss

 

BR, Petr

0 Kudos
Reply
7,213 Views
S3RD4R
Contributor I

Thank you so much. I will check this example further. 

0 Kudos
Reply
7,222 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

do not have example directly for this board, but see attached demo we got from Apps team.
Hope it helps.

BR, Petr

0 Kudos
Reply