AnsweredAssumed Answered

Different low power mode behavior when PE BDM is connected and when it's not

Question asked by Adelante sey on Mar 2, 2014
Latest reply on Mar 4, 2014 by Adelante sey

I wrote a program to be run on MC9S12XEG128 as below and program/debug it using P&E BDM. I tried to take the MCU to full stop mode and fast wake up the MCU using API after 13sec, then start the oscillator clock and at last turn on the PLL. By Toggling a Pin, there should be three different types of pulses with different Period (400us, then 100us and finally 25us). When I run the program in the debugger mode, it works fine and the result is as perfect as below:

Figure 1 : when we are in debugging mode and the debugging cable is connected.

But the problem arises when I disconnect the BDM cable and run the program on its own. Then I observe the following behavior:

Figure 2: when the MCU runs on its own with the debugger cable disconnected.

It seems that the MCU wakes up on the Oscillator not the internal clock in self clock mode. I know that the BDM takes the MCU into special single chip mode using BKGD pin and the MCU normally runs in the Normal single chip mode but I don't understand these different behaviors. Shouldn't the MCU work as it is programmed and run in the debugging mode and if not so, what should I do to get the expected result (I mean those three different periods) as in figure 1? I really would appreciate your help.

void main(void)

{

                MCU_init();                        // does some initialization           

                 _DISABLE_COP();

                EnableInterrupts;

                GPIO_STOP();   //disable other interrupt that can wakeup the MCU

 

/*Enable API*/

VREGAPICL = 0;

                VREGAPIR = 0xFFFF;                       //13 seconds

                VREGAPICL_APIE = 1;   

                VREGAPICL_APIFE = 1;

               

/*Full Stop Mode*/

PLLCTL = 0x09U;                                //enable fast wakeup   

CLKSEL_PLLSEL = 0;     

PLLCTL_PLLON  = 0;

CLKSEL_PSTP = 0;

asm ANDCC #0x6F;

asm STOP;

 

/*Disable API*/

VREGAPICL = 0;

 

ECT_Init();          

ECT_TC0 = ECT_TCNT + 400;

ECT_TSCR1 = 0x90;

PIN_Toggle = ~PIN_Toggle;

for(;;)

{

_FEED_COP();

}

}

 

/*the ECT-channel0 isr*/

__interrupt void isrVectch0(void)

{

                ECT_TFLG1_C0F = 1;      

                ECT_TC0 = ECT_TCNT + 400;       

                PIN_Toggle = ~PIN_Toggle;

                Count++;            

                if (Count == 5)

                {                             

                                PLLCTL_FSTWKP = 0;                       //start oscillator

                }

                if (Count == 30)

                {

PLLCTL_PLLON = 1;                          //turn on PLL

                                while(!CRGFLG_LOCK);               

                                CLKSEL_PLLSEL = 1;                          //switch to PLL

                }  

}

/*It just does some initialization, then activates the API timer (using internal RC and period of 13 seconds) and enables the fast wake up mode. After that, it takes the MCU to full stop mode and wakes up in self clock mode with internal Frequency of 1MHz. Then, it initiates the ECT timer ch0 with the value of 400. In the ECT_isr, after clearing its flag, the timer is reinitiated for another 400 bus clock. After a couple of times, I enabled the oscillator (which takes a while to be stabilized) and it automatically switches to oscillator clock which is 8MHz (bus clock = 4MHz). Finally, the clock is switched to 32MHz PLL (bus clock = 16MHz).*/

Attachments

Outcomes