LPUART DMA Tx + Interrupt RX

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPUART DMA Tx + Interrupt RX

2,874件の閲覧回数
SpoonMan
Contributor IV

Hi everybody,

I'm developing an application in which RT 1050 is the master MCU over an UART communication bus, while another MCU is slave.

Since there's a sort of data encoding/decoding in-between the two MCUs, on the master MCU I'm able to make the application more efficient by sending out a request using eDMA because I'm generating the request payload on the master MCU itself then I can put all the encoded data in a buffer and send it out by programming a DMA transfer, while for receiving the response packet I'm unable to use a DMA transfer because I don't know in advance the lenght of the response and I cannot read response lenght straight from response header since received data needs decoding BEFORE the actual content could be read.

To optimize the isolation between application code and LPUART peripheral, my idea was then to use DMA for Tx, while using interrupt for Rx, putting each received byte inside a FreeRTOS queue inside Rx ISR.

My question is: how this mixed configuration (eDMA + interrupt) could be achieved, possibly using Peripheral Config Tool?

0 件の賞賛
返信
5 返答(返信)

2,858件の閲覧回数
SpoonMan
Contributor IV

Ok, it looks like I figured out how to achieve the desired mixed configuration in subject, but manually.

In Peripherals Config Tool, I configured LPUART in eDMA mode and disabled "Enable RX eDMA channel" flag, then I specified my own "transfer callback function name" in "LPUART eDMA handle" section to catch when Tx DMA transfer finishes.

To start queueing data in FreeRTOS queue through Rx interrupt mode, I then had to manually enable Rx interrupt:

LPUART_EnableInterrupts(LPUART1, kLPUART_RxDataRegFullInterruptEnable);

Then I had to implement my own LPUART1_IRQHandler() to fill the Rx FreeRTOS queue with received data:

uint8_t temp = LPUART_ReadByte(LPUART1);
xStreamBufferSendFromISR(rxQueue, (void*)&temp, 1, &xHigherPriorityTaskWoken);

Another very annoying thing is that I had to manually add ISR priority initialization to avoid FreeRTOS to get stuck because of priority too high by manually calling after peripheral initialization:

NVIC_SetPriority(DMA0_DMA16_IRQn, 5);
NVIC_SetPriority(LPUART1_IRQn, 5);

since it looks there's no way to specify them from Config Tool.

Suggestions to improve the above workflow, which honestly I don't like so much?

0 件の賞賛
返信

2,793件の閲覧回数
Pablo_Ramos
NXP Employee
NXP Employee

Thanks for your interest in NXP tools.

Config Tools is only for configuration, you can initialize the interrupt and change priority of the peripheral, however the content of the IRQ depends of the implementation an should be made manually.

In the following images you can see where you can enable and change the priority level for LPUART1 and DMA0.

Pablo_Ramos_0-1730156502758.pngPablo_Ramos_1-1730156509121.png

These changes are reflected on the NVIC configuration

Pablo_Ramos_2-1730156515665.png

Hope it helps you!

0 件の賞賛
返信

2,782件の閲覧回数
SpoonMan
Contributor IV

Hello @Pablo_Ramos

thanks for your interest in my problem.

First of all, sorry if in my first post I forgot to mention I'm sticked to MCUXpresso IDE v11.7.0 build 9198 with Config Tools - Peripherals Tool v10.0.0.202301120728.

Secondly, if I choose eDMA mode for LPUART peripheral, config tool appears like this:

SpoonMan_0-1730192216529.pngSpoonMan_1-1730192250131.pngSpoonMan_2-1730192281882.png

and, as you can see, there's no way to set interrupts priorities.

I already tried to switch Mode to "interrupt", "transfer" or "freertos" but none of them is showing the settings you're showing to me in your screenshots.

 

 

0 件の賞賛
返信

2,760件の閲覧回数
Pablo_Ramos
NXP Employee
NXP Employee

Hi @SpoonMan,

You can try configured it directly on the NVIC peripheral.

You just need to add an interrupt and select the LPUART you want to use.

Pablo_Ramos_3-1730413139357.png

In the generated code you will find that the priority is set and IRQ is enable.

Pablo_Ramos_1-1730413125655.pngPablo_Ramos_2-1730413132025.png

 

 

0 件の賞賛
返信

2,815件の閲覧回数
SpoonMan
Contributor IV
bump?
0 件の賞賛
返信