Stop mode migrating between MPC5748G and MPC5746C

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

Stop mode migrating between MPC5748G and MPC5746C

1,365 Views
yankuang1
Contributor III

I use the stop mode code shown in the attachment,Code can run on the MP5748G, but run on the MPC5746C, can not enter the stop mode.What is the difference between 5746c and 5748g in low power mode configuration?

3 Replies

1,110 Views
cholland
Contributor V

If anybody comes across this, the line while(MC_MS.GS.B.S_CURRENT_MODE = 0xA); is incorrect.

See the following link Solved: Re: MPC5746C: STOP Mode - NXP Community

0 Kudos

1,186 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,
I see no issue here. I just made test and only thing I have to remark is that you have to enter STOP0 from RUN0-3 mode.

pastedImage_1.png

See my example code.

Peter

1,109 Views
cholland
Contributor V

@petervlna 

Hi Peter,

I am having trouble with this.

I am trying to run example in the Cookbook (AN2865 - Qorivva Simple Cookbook.pdf), plus the example in this post.

In this example, I see that it looks like it is trying to transition to Stop mode, which is what mine is doing.

In this example, It doesn't actually go into stop mode. You can see in the register that the current mode is RUN0.

I don't quite understand that part. It should run the line while(MC_ME.GS.B.S_CURRENT_MODE != 0xA); ,then stop at while (MC_ME.GS.B.S_CURRENT_MODE != 0x7A) because it would be in STOP_MODE.

I just don't understand why it is not working. The RTC part works. I have tested that.

All the registers appear to be correct. (See below) 

The RTC event flag is set (RTC.RTCS.RTCF = 1). I configured Stop mode. I am entering Stop Mode from RUN3 mode, but it just sits at transition mode. Never goes into Stop Mode, nor does it recover from stop mode.

Thank you

//=======================================================================================================================
// PCTL_WKPU = 93.  WKPU_RTC_STM = 1
//=======================================================================================================================
void WKPU_test(UINT32 _param)
{

#define TIMER_LOAD (0x7D000)

TARGET_MODE_T mode;

/* Enable Peripheral */
MC_ME_set_run_mode(PCTL_WKPU, ME_RUN_PC_7, ME_LP_PC_7);

/* Configure Wakeup Unit for low power exit */
WKPU.WIREER.R = WKPU_RTC_STM; /* Enable rising edge events */
WKPU.WIFEER.R = WKPU_RTC_STM; /* Enable falling edge events */
WKPU.WIFER.R = WKPU_RTC_STM; /* Enable analog 'glitch' filter */
WKPU.WRER.R = WKPU_RTC_STM; /* Enable wakeup events for RTC */
//WKPU.IRER.R = WKPU_RTC_STM; /* Enable wakeup for RTI */
WKPU.WIPDER.R = 0xFFFF; /* Enable WKPU pins pullups to stop leakage*/
WKPU.WISR.R = 0xFFFF; /* Clear all wake up flags */

LEDS_init(0);
SWTCH_init();

/* Save mode before entering STOP mode */
mode = MC_ME_get_current_mode();

while(1)
{
RTC_set_int_timer(TIMER_LOAD);

WKPU.WISR.R = 0x2; /* Clear wake up flag RTC */

/* Enter Stop Mode */
MC_ME_mode_change(TARGET_MODE_STOP0);

/* ON STOP MODE EXIT, CODE CONTINUES HERE: */
while(MC_ME.GS.B.S_CURRENT_MODE != mode) {}
LEDS_all_off();

RTC_set_int_timer(TIMER_LOAD);

WKPU.WISR.R = 0x2; /* Clear wake up flag RTC */

/* Enter Stop Mode */
MC_ME_mode_change(TARGET_MODE_STOP0);

/* ON STOP MODE EXIT, CODE CONTINUES HERE: */
while(MC_ME.GS.B.S_CURRENT_MODE != mode) {}
LEDS_all_on();

}
}

 

 

//=======================================================================================================================
//PCTL_PIT_RTI = 91
//=======================================================================================================================
void RTC_set_int_timer(const UINT32 _rtcval)
{
#define CLK_SEL (0x2)
// #define RTC_VAL (0x0007D000) //1 Second
// #define RTC_VAL (0x0003E800) //0.5 Seconds at 512,000 Hz

/* Enable Peripheral */
MC_ME_set_run_mode(PCTL_PIT_RTI, ME_RUN_PC_7, ME_LP_PC_7);

//INTC_enable_interrupt(INTR_RTC);
//RTC.RTCC.B.RTCIE = 1;

RTC.RTCC.R = 0x0; /* Clear CNTEN to reset RTC, enable reloading RTCVAL*/
RTC.RTCC.B.FRZEN = 1;
RTC.RTCC.B.DIV32EN = 1;
RTC.RTCC.B.CLKSEL = CLK_SEL;
RTC.RTCS.B.RTCF = 1; /* Clear RTC flag */
RTC.RTCVAL.R = _rtcval;
RTC.RTCC.B.CNTEN = 1;
}

 

//=======================================================================================================================
void MC_ME_mode_change(TARGET_MODE_T _target_mode )
{
UINT32 reg;

/* Can only enter stop mode from Run Mode 0..3 */
reg = (_target_mode << 28) | (KEY);
MC_ME.MCTL.R = reg;
reg = (_target_mode << 28) | (KEY_INVERTED);
MC_ME.MCTL.R = reg;

while(!MC_ME.GS.B.S_PLLON); //ME_GS Wait for PLL stabilization.
while(MC_ME.GS.B.S_MTRANS); //Wait for mode transition to complete
while(MC_ME.GS.B.S_CURRENT_MODE != _target_mode);

}

Registers.png

0 Kudos