S12ZVL32 STOP mode accident

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S12ZVL32 STOP mode accident

跳至解决方案
1,141 次查看
fanziyu
Contributor IV

hi,

the MCU work well most of the time but sometimes the amount of current consumed is about 10Ma after receive LIN sleep command (0x3c),it is still in normal mode by monitoring bus output,then if i send LIN sleep command again,MCU will go sleep mode well .


I am using S12ZVL32.
I put the MCU in full stop mode by LIN (0x3c) and wake up by input active interrupt;
I judged the mode by current measurement and bus output(ECLKCTL_NECLK=0).

problem 1:__asm(ANDCC #0x7F); __asm(STOP); // Are these two instructions going to make the MCU enter the stop mode without any other prerequisites?

problem 2:I have two guesses, enter stop mode failure or break out of stop mode through the default interrupts of MCU systems which I not configurate in the programm.


Something incomprehensible has happend when I disable the TIMER interrupt before STOP instruction,MCU always work successfully.


//Experiments show that ecu_enter_sleep_mode() will be always executed after receive sleep command LIN(0x3c)
void ecu_enter_sleep_mode(void)
{
      SCI0ASR1_RXEDGIF = 1;
      SCI0ACR1_RXEDGIE = 1;
      //TIM0TIE = 0x00;//timer interrupt is enabled all the time.if i disable the timer interrupt during stop mode,MCU always                                     work well.
       port_set_low_power_mode();
       cpu_set_stop_mode();//#define cpu_set_stop_mode() { __asm(ANDCC #0x7F); __asm(STOP); }
}
void wake_up_ecu(void)
{
         // TIM0TIE = 0x21;//the instruction should be added if disabled before.
         port_init();
}

// Suppose cpu_set_stop_mode() let the MCU go into stop mode.
// Experiments show that When an exception occurs ,the MCU break out of stop mode not through SCI0 interrupt program
// I'm sure that I only use TIMER interrupt and input active interrupt.Could it be the system's default interrupt program?
void sci0_isr_handler(void)
{
      if (SCI0ASR1_RXEDGIF == 1 && SCI0ACR1_RXEDGIE == 1) /* An active edge on the receive input has occurred */
      {
            SCI0ACR1_RXEDGIE = 0;
            SCI0ASR1_RXEDGIF = 1;
      }
}
It is a long time since I am trying to fix this problem and now I have no other ideas to fix it.

1 解答
838 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Yes, only the two instructions are required to put the MCU into Stop Mode.

It seems like the Timer is the wake-up source. Because if there is a pending interrupt while the STOP instruction is being executed, it will prevent the MCU from entering the Stop mode.

Is there a problem disabling the timer interrupt in your application?

Regards,

Daniel

在原帖中查看解决方案

0 项奖励
4 回复数
839 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

Yes, only the two instructions are required to put the MCU into Stop Mode.

It seems like the Timer is the wake-up source. Because if there is a pending interrupt while the STOP instruction is being executed, it will prevent the MCU from entering the Stop mode.

Is there a problem disabling the timer interrupt in your application?

Regards,

Daniel

0 项奖励
838 次查看
fanziyu
Contributor IV

Hi,

Thanks for your reply.There is no problem disabling the timer interrupt in the application.

But there is still a problem confused me that :   Do you mean when the __asm(STOP) is being executed suddenly  an interrupt generated,then MCU go to stop mode failed?

STOP process               //An interrupt between 1 and 6 will cause the STOP instruction to fail ? 

1:(SP)-$0002 SP;
2:(SP)-$0002 SP;
3:(SP)-$0002 SP;
4:(SP)-$0002 SP;
5:(SP)-$0001 SP;
6: STOP ALL Clocks

ANDCC Description: 

if the I mask bit is cleared,there is a 1-cycle delay before the system allows interrupt requests .This prevents interrupts from occurring between instructions in the sequences CLI,WAI and STOP.

I have used below programm ,it has the same problem that sometimes the the amount of current consumed is about 10Ma after receive LIN sleep command (0x3c)

void ecu_enter_sleep_mode(void)

{

   SCI0ACR1_RXEDGIE = 1; /* Enable receive input active edge interrupt */
   SCI0ASR1_RXEDGIF = 1;

   //TIM0TIE = 0x00;                           //timer interrupt is enabled all the time.if i disable the timer interrupt during stop                                                             mode,MCU always work well. 
   port_set_low_power_mode();
   DisableInterrupts;                            //from 0N22G ERRATA Shutdown sequence is not interruptible until STOP;
   ADC0_stop_current_workaround();//from 0N22G ERRATA

   ADC0CTL_0 = 0X00;                      //ADC is disabled
   cpu_set_stop_mode();                    //#define cpu_set_stop_mode() { __asm(ANDCC #0x6F); __asm(STOP); }

}

0 项奖励
838 次查看
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

The code masks interrupts, disables ADC and clears the interrupt mask again. It the Timer triggers during the ADC operation, the interrupt becomes pending. Once I bit gets cleared, the Stop instruction will be executed but because there is a pending interrupt, it will wake it up. 

You can place a few NOP instructions after CLI and before STOP. 

If there is a pending interrupt, it will be served before the MCU enters Stop Mode.  

But I would disable the Timer interrupt anyway, so that it can't trigger during the STOP instruction execution before clocks are disabled.  

Regards,

Daniel

838 次查看
fanziyu
Contributor IV

Thanks for your  support!

thanks and regards

wenbin

0 项奖励