howto switch into stop3 mode with my MC9S08DZ32

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

howto switch into stop3 mode with my MC9S08DZ32

1,098 Views
kelly1966
Contributor I

Hello

I have a question about my MC9S08DZ32 which I've been experimenting for a five of weeks.


I'm trying unsuccessfully for several days to move the MCU into „stop3 mode“ and wake-up the MCU via MSCAN.

I also have already read the AN3387 and tried to implement AN2255 and AN2283 but without success (nothing happens).


Now my question:

What I have to do if I want to switch the MCU into the stop3 mode and stay there as long as it receives a message via MSCAN (wake-up).


Is there a specific command for switching the modes or to trigger a specific event or set a flag?


Thank you for your help



TOM


You see some part of my code in the attachment

Original Attachment has been moved to: main-(with-stop3).c.zip

Labels (1)
0 Kudos
8 Replies

725 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Hi Thomas

To enter to stop mode you need executing a STOP instruction under the conditions as shown in Table 3-1

pastedImage_0.png

Also check the WUPIE on MSCAN Receiver Interrupt Enable Register (CANRIER)


Have a great day,
Vicente

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

725 Views
kelly1966
Contributor I

Dear Vicente,

A big thanks for your quick answer.

Here is my implemented code, but it don't work.

The MCU spent ~ 13mA and the I can't try the Wake-Up-Iq

And I don't know why...

// ==>> Code

     CANCTL0 |= 0x04; // WUPE = 1 ==> MSCAN Wake-Up enable

     CANRIER |= 0x80; //In CANRIER Bit7 WUPIE = 1

     SOPT1 |= 0x20; // STOPE = 1, SOPT1 Bit5

     SPMSC1 &= ~0x0C; // LVDE + LVDSE = 0, SPMSC1 Bit2 + Bit3

     SPMSC2 &= ~0x01; // PPDC = 0, SPMSC2 Bit0 für Stop3 ohne BDM und untervoltage detection

     This Register I can't find

     //BDCSCR &= ~0x80; // ENBDM = 0 in Register BDCSCR, BDCSCR Bit7

<<==

Is it possible to take a asm command to switch into the stopmade?

And I need your help along

Thanks for your Response

  TOM

-- was that the right button?

0 Kudos

725 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Hi Thomas

Sorry for the late response,

please check the attached file this is a code for the S08QE that set it to wake up using the KBI, this can help you. unfortunately I am out of the office to create a project with the DZ,

Please let me know if this help you.

0 Kudos

725 Views
kelly1966
Contributor I

Hi Vicente,.

I have unfortunately no a file received, can you send it again?

Big Thanks

TOM

0 Kudos

725 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Hi

Here is

0 Kudos

725 Views
vicentegomez
NXP TechSupport
NXP TechSupport

or....

void main(void)

{

 

  // Following a reset, BUSCLK = 4MHz

  SOPT1_STOPE = 1;//     stop mode enable

  SCI1BD = 26;       // SCI baud rate = 4MHz/(16*26)=9615 bps

  SCI1C1 = 0;  //default settings

  //enable transmitter and receiver pins, enables receiver interrupt

  SCI1C2 =  SCI1C2_TE_MASK |  SCI1C2_RE_MASK | SCI1C2_RIE_MASK;

  PTCDD_PTCDD0 =  1; //PTC0 as output

  PTCD_PTCD0 = 1; // PTC0 off

  PTCDD_PTCDD1 =  1; //PTC1 as output

  PTCD_PTCD1 = 1; // PTC1 off

 

  PTADD = 0;       //PTA as input

  PTAPE = PTAPE_PTAPE2_MASK;  // PTA2 pull up enables

  KBI1PE = KBI1PE_KBIPE2_MASK; //enable interrupt 2

  KBI1SC = KBI1SC_KBIE_MASK ; //KBI enable ,detect edges only

  KBI1ES = 0; // Falling edge eneble

 

  EnableInterrupts;

  

  for (;;)

  {

    __RESET_WATCHDOG();

   

    asm ("STOP");

      

    PTCD_PTCD1 = ~PTCD_PTCD1;

      

  }

 

}

/***************************************************************************************/

void interrupt VectorNumber_Vsci1rx SCI1RX_ISR(void)

{

 

  (void) SCI1S1;       // read SCIS1 register for clear RDRE flag

  u8receiver = SCI1D;

  

  SCI1D = u8receiver;

  if (u8receiver == 'l') {

   

  PTCD_PTCD0= ~ PTCD_PTCD0 ; //toggle PTCD0

  }

}

/***************************************************************************************/

                       

void interrupt VectorNumber_Vkeyboard  kbi_ISR(void)

{

  int i = 5000;  //delay

  while :smileyinfo:

   {

    i--;

  }

  KBI1SC_KBACK = 1; //  Acknowledge KB Interrupts

   

    PTCD_PTCD0 = ~PTCD_PTCD0;

   

 

}

 

/***************************************************************************************

Regards

Vicente

0 Kudos

725 Views
kelly1966
Contributor I

Hallo Vicente,

I do the same I think, but it don't work...

Bool ENTER_STOP_MODE = FALSE; // starts in Normal-Mode

Bool MCU_IS_STOPPED = FALSE;  // the mcu isn't stopped

void main(void)  {// Clear COP Watchdog timeout

    SOPT1 = 0x20;        // STOPE = 1, SOPT1 Bit5

    SPMSC1 &= ~0x0C; // LVDE + LVDSE = 0, SPMSC1 Bit2 + Bit3

    SPMSC2 &= ~0x01; // PPDC = 0, SPMSC2 Bit0 Stop3 with BDM

   

    MCGC1 = 0xB8;

    MCGC2 = 0x36;

    MCGC3 = 0x00;   

    while(!(MCGSC&0x02)); // Wait until the initialization cycle of the external crystal clock is completed

   

    // isrTimer1 configure and aktivate

    TPM1MODH = 0xFD; // Timer1 Overflow

    TPM1MODL = 0xD0;

    TPM1SC = 0x4F;

       

    MSCANInit();// CAN Schnittstelle initialisieren

  //  CANCTL0 |= 0x04;  //  WUPE = 1  ==> MSCAN Wake-Up enable 

  //  CANRIER |= 0x80; // Enable Wake-Up IRQ

  //  RUN:  CANE = 1, CSWAI = X, SLPRQ = 0, SLPAK = 0  

  //  WAIT: CANE = 1, CSWAI = 0, SLPRQ = 0, SLPAK = 0

    EnableInterrupts; 

    for (;;)    {

        if (ENTER_STOP_MODE) { // enter stopmode

            if (!MCU_IS_STOPPED) {

                MCU_IS_STOPPED = TRUE; // the mcu is now stopped

                CANCTL0 |= 0x02;  //  SLPRQ = 1  ==> MSCAN SLEEP

                CANCTL1 |= 0x02;  //  SLPAK = 1  ==> MSCAN SLEEP

                asm ("STOP"); // switch into stop3 Mode      

            }

        }

    }   

// The isrTimer1 sets the (Bool ENTER_STOP_MODE = True);   

// In my canWakeUp irq I  set (ENTER_STOP_MODE = MCU_IS_STOPPED = false) again

// After "asm (STOP);" the mcu ever reset

Thanks for your answer

Tom

0 Kudos

725 Views
vicentegomez
NXP TechSupport
NXP TechSupport

Please remember that in some kind of stop mode, the debuger does not work, or if you are using the debuger probably you did not reach the stop mode

0 Kudos