Wake-up from pseudo stop mode and RAM retention for S1912ZVCA product

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

Wake-up from pseudo stop mode and RAM retention for S1912ZVCA product

1,497 Views
bhushanpatil
Contributor I

Hi,

 

I am using S1912ZVCA19F0WKH (magni v 192kB) controller.

 

I have done this configuration for API to generate API interrupts

 

      

main()

{

/* Autonomous Periodical Interrupt initialisations. */

       /*CPMUACLKTR API clock trimming register*/

       CPMUACLKTR_ACLKTR0 = 1;

CPMUACLKTR_ACLKTR1 = 1;

CPMUACLKTR_ACLKTR2 = 1;

CPMUACLKTR_ACLKTR3 = 1;

CPMUACLKTR_ACLKTR4 = 1;

CPMUACLKTR_ACLKTR5 = 0;

       /*CPMUAPICTL API control register settings*/

CPMUAPICTL_APICLK = 0; //Clock source for API is ACLK

CPMUAPICTL_APIES = 1; //External wave form visible at pin (Reference: Pg 250)

CPMUAPICTL_APIEA = 1; //Waveform can be accessed externally

CPMUAPICTL_APIE = 1; //API interrupt enabled whenever APIR timeout happens.

CPMUAPICTL_APIF = 1; //Clear the interrupt flag by writing 1

 

       /*Select the time for API*/

       /* Refer to Pg no: 253 */

CPMUAPIRH = 0xE7;

       CPMUAPIRL = 0xFF;

 

/*CPMU clock initialisations*/

       CPMUCLKS_PSTP = 1; //Oscillator 4Mhz continues to run --> Pseudo stop mode

CPMUCLKS_CSAD = 1; // COP stopped in stop mode

CPMUCLKS_PRE = 1; //RTI enabled in pseudo stop mode

CPMUCLKS_PCE = 0; //COP disabled in Pseudo stop mode

       CPMUCLKS_RTIOSCSEL = 1; //RTI clock source is OSCCLK

CPMUCLKS_COPOSCSEL1 = 0;

CPMUCLKS_COPOSCSEL0 = 1; //COP clock source is OSCCLK

 

for(;;)

{

/*Set of instructions*/

 

CPMUAPICTL_APIFE = 1; //API is enabled; this bit is set to 1 to start API timer*/

__asm(ANDCC #0x6F);

__asm(STOP);  //Enter pseudo stop mode

}

}

 

Using the above configuration; I am able to get API interrupt without stop command in main function.

But if I use stop command device will not wake up once it enters stop mode.

I want to call main function again in API interrupt function without losing any ram data.

 

interrupt ISR_API( void )

{

       if (CPMUAPICTL_APIF)

       {

/* Clear the interrupt flag. */

CPMUAPICTL_APIF = 1;     /* APIF. Clear the interrupt flag by writing 1. */

/*Call the operation to be performed*/

main();

       }

}

 

Kindly help me regarding this.

 

Regards,

Bhushan

Labels (1)
0 Kudos
3 Replies

743 Views
RadekS
NXP Employee
NXP Employee

!Hi Bhushan,

I can’t see anything wrong in your code except calling main() inside main() routine.

This might simply lead to the stack overflow.

How do you detect the MCU wake-up?

Please be aware that when MCU enters into stop mode, internal clocks are disabled and BDM interface connection is lost. So, the MCU wake-up cannot be debugged by debugger. You have to use some other signalization like LEDs, check ECLK signal, …

The STOP mode API wake-up example code is here:

https://community.nxp.com/docs/DOC-330295

Attached is simple example code for ACLK trimming.

I hope it helps you.

Have a great day,
Radek

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

0 Kudos

743 Views
manishsangram
Contributor IV

We are using S12ZVMC128

PE defined STOP function is called form main.

#define Cpu_SetStopMode() \

  /*lint -save  -e950 Disable MISRA rule (1.1) checking. */\

  {__asm(ANDCC #0x7F); __asm(STOP); } \

Can interrupts be lost ?

SCI is connected to a serial port but system does not respond to it (SCI RX). If the Stop call is removed it works fine.

0 Kudos

743 Views
RadekS
NXP Employee
NXP Employee

Hi Bhushan/Manish,

Idea: You call __asm(ANDCC #0x6F); command before STOP instruction. This way you clear I-bit and enable I-bit maskable interrupts. However, there is a 1-cycle (bus clock) delay in the clearing mechanism for the I bit so that, if interrupts were previously disabled, the next instruction after a CLI will always be executed, even if there was an interrupt pending prior to execution of the CLI instruction.

Coud you please try to add one or more __asm(NOP); commands between __asm(ANDCC #0x6F); and __asm(STOP); commands?

About SCI wake-up from stop mode:

The SCI module is gated from bus clock = SCI does not work in STOP mode. However, you could use input active edge interrupt feature as part of SCI for wake-up from STOP mode. So, you have to switch SCI to the alternative map by AMAP bit and set SCIACR1_RXEDGIE bit for enabling Receive Input Active Edge Interrupt. For example:

void Go_Stop(void)

{

  SCI0SR2 = 0x80;  //Alternative Map - The registers labelled SCIASR1 (0x0000),SCIACR1 (0x0001), SCIACR2 (0x00002) are accessible

  SCI0ACR1 = 0x80; //Receive Input Active Edge Interrupt Enable - RXEDGIF interrupt requests enabled

  SCI0ASR1 = 0x80; //clear Receive Input Active Edge Interrupt Flag - RXEDGIF

  SCI0SR2 = 0x00;  //Back from Alternative Map

  asm STOP;        //Go to stop mode

}

In SCI interrupt routine you have to check RXEDGIF flag, clear them and disable this kind of interrupt. For example:

SCI0SR2 = 0x80; //Alternative Map

if(SCI0ASR1 & SCI1ASR1_RXEDGIF_MASK)

  {

    SCI0ACR1 = 0x00; //Receive Input Active Edge Interrupt Disable - RXEDGIF interrupt requests disabled

    SCI0ASR1 = 0x80; //clear Receive Input Active Edge Interrupt Flag - RXEDGIF

  }

SCI0SR2 = 0x00; //Back from Alternative Map

I hope it helps you.

Have a great day,
Radek

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