Wake up from STOP mode

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

Wake up from STOP mode

Jump to solution
2,240 Views
fabrizioimpinna
Contributor II

Dears,

I am working with a MC9S12ZVL and I need to put the micro in STOP mode and wake it up. When I put the micro in STOP mode I am not able to wake it up.

I should wake up the micro using the key-wakeup (KWU) interrupt of the port AD and L.

I have enabled the bit PIEADL/H of Port Interrupt Enable Register for the Port AD but it has no effect on the wake up of the device.

Could you give me any suggestions?

It should be possible to wake up the micro using AD and L ports, could you confirm it?

 

In case I was interested in using the XIRQ or the IRQ interrupts to wake up the micro, in reference manual it is written that the "I bit cleared in the condition code register". Where is it possible to find the asm instruction to clear that bit?

 

thanks in advance

 

Fabrizio

Labels (1)
Tags (4)
1 Solution
1,064 Views
iggi
NXP Employee
NXP Employee

Hi,

Yes, it is possible to wake-up the micro through these two ports.

You need to put the following code lines in the main function prior to enter Stop mode:

...

////////////////////////////////////////////////////////////////////////

/*** Digital input -> Support wakeup from stop ***/

PTAL_PTAENL=0;      // Disconnect from ADC channel (by default this bit is zero after reset; this instruction is not necessarily needed)

DIENL_DIENL0 = 1;  // Enable digital input buffer

/////////////////////////////////////////////////////////////////////

...

- Note that in order to enter Stop, two asm instructions must be executed:

asm ANDCC #0x7F;// clear S bit in Condition Code Register (CCR) - enable the stop mode.
               // If the S bit is not cleared then STOP instruction has no effect and is
               // executed as a dummy instruction NOP.
asm STOP;         // Now MCU is in STOP mode

- Usual instruction used to clear I bit is:

asm CLI;

In CodeWarrior, we use C instruction (which performs the asm CLI;):

EnableInterrupts;

See, the S12Z CPU reference manual for available asm instructions:

http://cache.freescale.com/files/microcontrollers/doc/ref_manual/S12ZCPU_RM_V1.pdf

Regards,

iggi

View solution in original post

4 Replies
1,065 Views
iggi
NXP Employee
NXP Employee

Hi,

Yes, it is possible to wake-up the micro through these two ports.

You need to put the following code lines in the main function prior to enter Stop mode:

...

////////////////////////////////////////////////////////////////////////

/*** Digital input -> Support wakeup from stop ***/

PTAL_PTAENL=0;      // Disconnect from ADC channel (by default this bit is zero after reset; this instruction is not necessarily needed)

DIENL_DIENL0 = 1;  // Enable digital input buffer

/////////////////////////////////////////////////////////////////////

...

- Note that in order to enter Stop, two asm instructions must be executed:

asm ANDCC #0x7F;// clear S bit in Condition Code Register (CCR) - enable the stop mode.
               // If the S bit is not cleared then STOP instruction has no effect and is
               // executed as a dummy instruction NOP.
asm STOP;         // Now MCU is in STOP mode

- Usual instruction used to clear I bit is:

asm CLI;

In CodeWarrior, we use C instruction (which performs the asm CLI;):

EnableInterrupts;

See, the S12Z CPU reference manual for available asm instructions:

http://cache.freescale.com/files/microcontrollers/doc/ref_manual/S12ZCPU_RM_V1.pdf

Regards,

iggi

1,064 Views
fabrizioimpinna
Contributor II

Hello,

I still have the same problem in trying to wake-up the the micro.

I can put the micro in standby using the command suggested by you but I cannot wake it up.

asm ANDCC #0x7F;// clear S bit in Condition Code Register (CCR) - enable the stop mode.
              // If the S bit is not cleared then STOP instruction has no effect and is
              // executed as a dummy instruction NOP.
asm STOP;        // Now MCU is in STOP mode

This is the PIM initialization in my code:

// --- digital input function enable --- [1] digital in [0] analog in

  DIENADL_DIENADL0 = 1;

  DIENADL_DIENADL1 = 1;

  DIENADL_DIENADL2 = 1;

  DIENADL_DIENADL3 = 1;

  DIENADL_DIENADL4 = 1;

  DIENADL_DIENADL5 = 1;

  DIENL_DIENL0 = 1; // REAR_DOME (Port L input enable register)

  // --- set direction --- [1] out [0] in

  // Inputs

  DDRADL_DDRADL0 = 0; // SMBT

  DDRADL_DDRADL1 = 0; // DOOR_OP

  DDRADL_DDRADL2 = 0; // ALL_LIGHTS

  DDRADL_DDRADL3 = 0; // LIGHT_SX

  DDRADL_DDRADL4 = 0; // LIGHT_DX

  DDRADL_DDRADL5 = 0; // DOORS

  // Outputs

  DDRS_DDRS3 = 1; // REAR_ON

  DDRP_DDRP3 = 1; // STATUS

  DDRP_DDRP5 = 0; // Debug LED demo board

  // -- set pull up connection --- [1] ON [0] Off

  PERADL_PERADL0 = 1;

  PERADL_PERADL1 = 1;

  PERADL_PERADL2 = 1;

  PERADL_PERADL3 = 1;

  PERADL_PERADL4 = 1;

  PERADL_PERADL5 = 1;

  // -- Polarity select register -- [1] Pull Down [0] Pull Up

  // Configure pull device and pin interrupt edge polarity on input pin

  PPSAD_PPSADL0 = 1;

  PPSAD_PPSADL1 = 0;

  PPSAD_PPSADL2 = 0;

  PPSAD_PPSADL3 = 0;

  PPSAD_PPSADL4 = 0;

  PPSAD_PPSADL5 = 0;

  PPSL_PPSL0 = 0;

  // -- Interrupt enable register -- [1] Enable [0] Disable

  PIEAD_PIEADH0 = 1;

  PIEAD_PIEADH1 = 1;

  PIEAD_PIEADL0 = 1;

  PIEAD_PIEADL1 = 1;

  PIEAD_PIEADL2 = 1;

  PIEAD_PIEADL3 = 1;

  PIEAD_PIEADL4 = 1;

  PIEAD_PIEADL5 = 1;

  PIEL_PIEL0 = 1;

  // --- Set initial value ---

  //PTS_PTS3 = 0; // Output Digital pin initial value REAR_ON

  PTP_PTP3 = 0; // Output Digital pin initial value STATUS

  PTP_PTP5 = 0; // Debug LED demo board

  // PWM output pin // PWM1 to PP1 (default configuration)

  MODRR1_PWM0RR = 1; // PWM0 to PT1                

  MODRR1_PWM2RR = 1; // PWM2 to PT0

This is the setting for the registers related to the STOP mode function:

 

  CPMUPROT = 0x26;

  CPMUOSC_OSCE = 0;

  CPMUCLKS_COPOSCSEL0 = 1;           

  CPMUCLKS_RTIOSCSEL = 0;            

  CPMUCLKS_PCE = 0;                  

  CPMUCLKS_PRE = 0;                  

  CPMUCLKS_COPOSCSEL1 = 0;           

  CPMUCLKS_CSAD = 0;                 

  CPMUCLKS_PSTP = 1;                  

  CPMUCLKS_PLLSEL = 0;

The interrupts of the PORT AD an Port L (VECTOR 66 and VECTOR 79) work properly when the micro is running.

When the micro is in stop mode and I put something on AD or L port nothing happens. I have checked and these port interrupts should be used to wake-up the micro (and you have confirmed it previously).

Could you confirm that these settings are ok and I do not miss other registers settings?

It is a long time since I am trying to fix this problem and now I have no other ideas to fix it.

Thanks a lot for the precious help

Fabrizio

0 Kudos
1,064 Views
fabrizioimpinna
Contributor II

Good morning Iggy,

any news about how to wake up from stop mode the micro using AD o L ports?

I hope the code lines I attached were useful to understand the problem.

Please ask me if you need further informations to try to help me in fixing this problem.

Thanks

Fabrizio

0 Kudos
1,064 Views
fabrizioimpinna
Contributor II

Dears,

some months ago I fixed the problem and I would like to share with you what I learnt.

All the settings I used to put in Stop and Wake-up the micro were correct, but I made a mistake.

The STOP instruction must be called in background so that when the micro wakes-up due to an event, the code starts from the first instruction after the STOP. If you put the stop instruction inside an interrupt routine, when the micro wakes-up it is not able to restart from the command row after the STOP instruction bacause it is inside an interrupt service routine and therefore the code goes in a sort of starvation condition.

I hope I is useful to someone that is working with Stop mode for the first time.

Fabrizio