S08 Family -- Stop3 Mode change I/O pins state (Problem) 

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

S08 Family -- Stop3 Mode change I/O pins state (Problem) 

1,584 Views
mariospelekis
Contributor III

Hi

I am using the MC9S08PA8 microcontroller from S08 Family.

I have already enable the Stop3 mode and works fine with an RTC (LPO~1KHz) every 1sec interrupt .

When RTC Interrupt occurred Stop3 mode stops and I toggle an I/O pin(Aseg Led) in order to watch the RTC timing.

After the Toggling of the Aseg Led  I execute the Stop3 instruction in order to stop the microcontroller again, so every 1sec the Aseg Led toggle its state.

All the above are working perfectly, BUT the Problem is that after 15sec(about) seems that the I/O pins change their state in a known state, different from their initialized state.

 

First, in the code i have set all I/O pins in an " known state " (Output Enable-Data Register=0).

 

Main LOOP:

void main(void) {

  DisableInterrupts;

  wdog_disable();

  ICS_FEI();

  Disp_Init();

  RTC_Init();

  KBI0P5_Init();

  asm stop;

  for(;;) {  }

}

------------------------------------------------------------------------------------------------------------------

CLOCK INIT:

void ICS_FEI(void)

{

  ICS_C1 = 0x04;   

  ICS_C2 = 0x20;   

  while(!ICS_S_LOCK);                 // wait clock to lock

  SYS_SOPT1_STOPE=1;

  PMC_SPMSC1_LVDE=0;

  SCG_C1=0x01;                          //RTC=1;

  SCG_C2=0x10;                          //NVM=1;

  SCG_C3=0x00;

  SCG_C4=0x00;                          //IRQ=0;

}

------------------------------------------------------------------------------------------------------------------

 

RTC INIT:

void RTC_Init(void){

  RTC_SC2=0x46;

  RTC_SC1=0x40;

  RTC_MOD=0x0001;

}

interrupt VectorNumber_Vrtc void  RTC_ISR(void)

{

  if(RTC_SC1_RTIF)RTC_SC1_RTIF = 1;

  Aseg^=1;                                       //LED Status

  asm stop;

}

------------------------------------------------------------------------------------------------------------------

Disp INIT:              //I/O Pins Initialize

void Disp_Init(void){

  Aseg_Init();

  Bseg_Init();

  Cseg_Init();

  Dseg_Init();

  Eseg_Init();

  Fseg_Init();

  Gseg_Init();

  ONEseg_Init();

  SUBseg_Init();

  DOseg_Init();

  UPseg_Init();

  TradeL_Init();

  ClrAllSeg();

}

void ClrAllSeg(void){

  Aseg=0;

  Bseg=0;

  Cseg=0;

  Dseg=0;

  Eseg=0;

  Fseg=0;

  Gseg=0;

  ONEseg=0;

  SUBseg=0;

  DOseg=0;

  UPseg=0;

  TradeL=0;

}

* everything is in this part is Defined in header file, for Example:

#define Aseg_Init()PORT_PTBOE_PTBOE6=1
#define AsegPORT_PTBD_PTBD6

------------------------------------------------------------------------------------------------------------------

Thanks in advance

     Pelekis Marios    

     Intelco Electronics

Original Attachment has been moved to: Stop3.rar

Labels (1)
7 Replies

988 Views
mariospelekis
Contributor III

Hello Stanislav and Diaz

Seems the problem solved!!

After 2-3 days of thinking and conversations, between 3 people here, we found that ILAD comes from non Reseting the Stack Pointer, which buffered from RTC interrupt.

Actually my code had a very very critical ERROR we had to notice earlier  :

--------------------------------------------------------------------------------------------------------------

interrupt VectorNumber_Vrtc void  RTC_ISR(void){

  if(RTC_SC1_RTIF)RTC_SC1_RTIF = 1;

  Aseg^=1;

  asm stop;                              <--ERROR          (NEVER RETURN FROM INTERRUPT)

}

{INTERRUPT NEVER END - Program Counter(PC) is getting lost}

---------------------------------------------------------------------------------------------------------------

For the reason above, nothing was running in my "main loop".

Also after a very specific number of RTC interrupt ticks, MCU had a RESET event, which caused from the same reason as above!!

Thanks Again

Pelekis Marios

Intelco Electronics

                                     

988 Views
david_diaz
NXP Employee
NXP Employee

Hello Marios,

I am glad to know your problem is solved. :smileyhappy:

Indeed, you should not enter the stop mode directly in this ISR because the I-bit is set (that means interrupts are disabled), so the next RTC counter overflow would not wake up the MCU. The STOP instruction must be executed outside the ISR; for example in main function.

Accept my apologies if I did not notice it before.

Have an excellent day.

David

0 Kudos

988 Views
Stano
NXP Employee
NXP Employee

Hello Marios,

I have investigate your SW, it looks good, as you wrote. If I understand you wel, the MCU ticks with LED with 1sec period properly and then occasionally - in about 15sec the MCU wakes up and changes the pin's setting. I suggest you to check the SYS_SRS register when this event arrives to investigate the reason of the MCU status change. Please check also the RESET pin in your application if it is not sensitive to such noise. The good option is to use the pull-up resistor about 1kOhm on this pin. Please let me know the result.

I hope it could help you.

Best Regards,

Stano.

988 Views
mariospelekis
Contributor III

Hello Stanislav,

Seems you are right for the reset of the mcu.

With Debugger connected in time <15sec I can stop in endless FOR (;;) any time I want.

After this time 15Sec (1)theStatus of the I/O pins change in a very specific state, (2)the Aseg LED remains in blinking state(every 1 sec) and (3)the debugger pop up "lost communication" message( when I try to set a breakpoint in the same position  as before)

From the above i can understand that the MCU has already restart.

I tried to capture the status of the SRS register.The one way to do this is to check the SRS bits with LEDs, but the problem is that I/O state change at this specific time, so i don't know what causes the reset!!

The other way is to read the status of SRS while debugging, BUT Debugger loss communication at this time(after 15 sec).

I dont think 15sec(15 Aseg blinks) until  reset(??) is random effect.

I found the sequence of making STOP3 mode work at :

1)HCS08 Automotive Low-Power Modes (AN3387)

2)How to Use Low Power Modes on the Newest S08 Devices(AN4441)

Its very critical to solve this problem!

P.s: the hardware has no problem at all and all of our PA (MCU) based products have pull-up resistors(10K) on the RESET pin.

Many Thanks

     Pelekis Marios

     Intelco Electronics

0 Kudos

988 Views
david_diaz
NXP Employee
NXP Employee

Hello Marios,

I agree with Stano about checking the SYS_SRS register when the event mentioned arrives.

If you have difficulties to check the SYS_SRS register, please refer to the sample code that I attached to this response.

The sample code evaluates the SYS_SRS register after each reset and sends information about the reset flags using the SCI module at 9600 kbps.

I made the project using CodeWarrior v10.x and the TWR-S08PT60 . You can migrate the project easily to your device.

I hope this material will be useful for you.

If I misunderstood your question, feel free to let me know.  I will be glad to help.

Have a great day.

David Diaz.

0 Kudos

988 Views
mariospelekis
Contributor III

Hello David and Stanislav

You were both right.

I made the code to response the SYS_SRS register status via SCI module as you told me, and the result was the following:

  • for time <15 sec(defore the MCU RESET), nothing comes to my Terminal(as expected).
  • after that time (while the problem occurs), ILAD come to my Terminal.

So the answer is that the MCU RESET comes from ILAD !!

What I do wrong in my STOP3 mode setup? What i have to do in order to make this work correctly?

Thanks for quick response to my problem.

Hope we will find the solution.

Best Regards,

   Marios Pelekis

   Intelco Electronics

0 Kudos

988 Views
Stano
NXP Employee
NXP Employee

Hello Marios,

If I understand you well, the software behave properly roughly 15 seconds (ticks LED each seconds) and then it fails. One think could be the RAM stack overflow - please check it, whether it not slowly increments by each interrupt (LED tick).

Best Regards,

Stano.

0 Kudos