UART with DMA going to Standby mode

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

UART with DMA going to Standby mode

跳至解决方案
2,131 次查看
shijiaguo
Contributor II

Hello all, 

 

I'm trying to use UART with DMA here, however I'm having some problems when I'm going to standby mode: it wouldn't go to standby. 

 

So what I found was that if I enable DMA in my init procedure:

LINFlexD_0.DMATXE.R = 0xFFFF; /* enable DMA */
LINFlexD_0.DMARXE.R = 0xFFFF; /* enable DMA */

(and after that I'm not even doing anything with the actual DMA module)

and disable them in my prepare to go to standby procedure:

LINFlexD_0.DMATXE.R = 0; /* disable DMA */
LINFlexD_0.DMARXE.R = 0; /* disable DMA */

I will NOT be able to go to standby. If I check the registers of TXE and RXE, after the disabling, they are both 0. 

 

However, if I don't enable it from the beginning, it WILL go to standby. 

 

Any idea if I'm disabling this in the wrong way?

Original Attachment has been moved to: main.c.zip

标签 (1)
标记 (1)
1 解答
1,707 次查看
gvictorio
Contributor III

shijiaguo‌, seems like it matters the order in which things are done when preparing the LINFlexD for a transition to STANDBY. Disabling the LINFlexD channel DMA before starting to prepare does the trick. i.e. kind of following the reverse order of the driver initialization.

/* Disable DMA First */

LINFlexD_0.DMATXE.R = 0; /* disable DMA */
LINFlexD_0.DMARXE.R = 0; /* disable DMA */

/* Now disable LINFlexD interrupts, clear ISR pending flags, etc */

在原帖中查看解决方案

5 回复数
1,708 次查看
gvictorio
Contributor III

shijiaguo‌, seems like it matters the order in which things are done when preparing the LINFlexD for a transition to STANDBY. Disabling the LINFlexD channel DMA before starting to prepare does the trick. i.e. kind of following the reverse order of the driver initialization.

/* Disable DMA First */

LINFlexD_0.DMATXE.R = 0; /* disable DMA */
LINFlexD_0.DMARXE.R = 0; /* disable DMA */

/* Now disable LINFlexD interrupts, clear ISR pending flags, etc */

1,707 次查看
shijiaguo
Contributor II

Works like magic

0 项奖励
1,707 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

usually the pending interrupt from peripherals may block the mode transition. So ensure all peripherals interrupt flags are cleared before entering low power mode.

Also check the DMA is really inactive before you clear DMARXE/DMATXE registers.

 

Or please share the code that shows the issue, so we can check/test it.

BR, Petr

1,707 次查看
shijiaguo
Contributor II

So in order to get rid of the side effect of DMA, I didn't even call the DMA module after my UART init. 

My code is very long and hard to extract, so I'm taking one of the examples from here:

Example MPC5748G Standby mode GHS614 

and adding my part of code into it. Kinda can give an idea of how I'm doing it. See the attached file in the main dialog for my code.

If you comment out these two lines in static void UART_initChannel0(void):

LINFlexD_0.DMATXE.R = 0xFFFF; /* enable DMA */
LINFlexD_0.DMARXE.R = 0xFFFF; /* enable DMA */

It should go to standby. However, if you just run the code as is, although in the static void UART_prepareStandby(void) function, those are disabled, it won't go to standby

0 项奖励
1,707 次查看
shijiaguo
Contributor II

Also I made sure that all interrupts in UART and DMA were cleared and disabled. Please see if I'm missing something. Thank you! @Petr Stancik

0 项奖励