How do I exit stop2 mode?

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

How do I exit stop2 mode?

6,447 次查看
Shankman
Contributor II
Hi,

I am attempting to use stop2, once the board enters stop mode it does not exit, it should exit the mode every 1sec due to the RTI interrupt but it is stuck. Here is my code any ideas why?

void TxAccel(void)
{

/**************************************************************
* TX_accel initialization
**************************************************************/
LED1=LED_ON;
EnableInterrupts;
SOPT_STOPE= 1; /*Enable stop modes*/
SRTISC_RTIS0= 1; /* Real-Time Interrupt Delay Select Bit 0 */
SRTISC_RTIS1= 1; /* Real-Time Interrupt Delay Select Bit 1 */
SRTISC_RTIS2= 1; /* Real-Time Interrupt Delay Select Bit 2 */
SRTISC_RTIE= 1; /* Real-Time Interrupt Enable */
SRTISC_RTICLKS= 0; /* Real-Time Interrupt Clock Select internal */

/* Enable deep sleep mode stop2. */
SPMSC2_PPDC= 1; /* Partial Power Down Control */
SPMSC2_PDC= 1; /* Power Down Control */

//TX_accel main loop

for (;:smileywink:
{
/ADC code

_asm stop;

} /* end for */

} /* end main */

thanks in advance

Kris
标签 (1)
0 项奖励
回复
10 回复数

1,761 次查看
marcom
Contributor I

I have same identical problem.... internal osc, stop2 and wake up through RTI... nothing to do, sleeps sleeeps sleeeps, but in debugger mode it's ok.

CW 5.1 SE .... hints or news????

 

thanks

0 项奖励
回复

1,761 次查看
fls_zen
Contributor I

I recently discovered that for MC9S08QG8 and QG4 MCUs, the SOPT1 register needs to be written *after* you write SPMSC2 and clear the SPMSC2_PPDACK flag. Apparently, if SOPT1 is initialized first, the flag doesn't clear. The device initialization code produced by CW 5.1 isn't very helpful because it sets SOPT1 first, so it kind of gets you off on the wrong foot when writing the init routine for resuming from stop 2. And of course port I/O won't work until the PPD is ack'ed and I don't think the BDM can be used with STOP 2.

I know I'm resurrecting an old thread here, but it would have saved me a couple hours if I had known this to start with. :smileyhappy:

0 项奖励
回复

1,761 次查看
Nik
Contributor III
I too have this problem.  Sleeps in STOP2, works wit the debugger, but not without.  Xosc starts after IRW, but otherwise dead.  Did you solve this?
 
Thanks,
-
Robert
0 项奖励
回复

1,761 次查看
koehler916
Contributor II

I also have the same problem... I have an RTC interrupt that wakes the MCU out of stop2 mode and this works with the debugger, but after powering the dev board off and then powering back on, the RTC interrupt no longer wakes up the MCU. I also tried flashing the target regularly instead of straight to debug mode with no luck.

 

Has anybody found a solution for this??

0 项奖励
回复

1,761 次查看
fls_zen
Contributor I

In STOP 2, the RTC interrupt will never fire. It will wake up the MCU and take the reset vector, but the RTI interrupt won't fire. The docs note this.

I think what you're seeing is the presence of the BDM. When the BDM is attached it will set ENBDM=1, which prevents the MCU from entering STOP 1 or STOP 2 modes, allowing only STOP 3. This is consistent with the stop mode selection table in the data sheet. (Table 3-1 for MC9S08QG8)

When you power the board off and back on, I'm guessing the BDM is no longer connected, therefore it can actually go to STOP 2 thus your interrupt doesn't fire.

0 项奖励
回复

1,761 次查看
Shankman
Contributor II


marcom wrote:

I have same identical problem.... internal osc, stop2 and wake up through RTI... nothing to do, sleeps sleeeps sleeeps, but in debugger mode it's ok.


CW 5.1 SE .... hints or news????



thanks






Sorry mate only news i have so far is it still sleeps and sleeps, when i get it working ill make sure to reply to you or vice versa hopefully

Cheers!
0 项奖励
回复

1,761 次查看
peg
Senior Contributor IV

Have you tried a handsome prince?

 

Sorry!

 

0 项奖励
回复

1,761 次查看
rhinoceroshead
Contributor I
You may want to temporarily replace the stop instruction with a wait instruction just to be sure that the interrupt and prm are configured correctly.  If they are, then the only other thing I might suggest is to set all of the SRTISC registers simultaneously instead of 1 at a time.  It looks like you are selecting the internal clock last and it may not be possible to change the clock source after you have already started the RTI clock by selecting the divider.  Stop2 will not work with RTI using the external clock since it is shut off.  Look at the data sheet page 38, item 4.  If this is what is happening in your case, then everything you are experiencing makes sense.
 
Code:
LED1=LED_ON;EnableInterrupts;SOPT_STOPE= 1; /*Enable stop modes*//* Real-Time Interrupt Enable   Real-Time Interrupt Clock Select internal   Real-Time prescale set to ~1 ms */SRTISC = 0x57;       <--  write all config bits at the same time/* Enable deep sleep mode stop2. */SPMSC2_PPDC= 1; /* Partial Power Down Control */SPMSC2_PDC= 1; /* Power Down Control */

 
0 项奖励
回复

1,761 次查看
rhinoceroshead
Contributor I
It looks like the internal clock is selected by default, so maybe this isn't what's happening in your case.  But I would still try writing the bits at the same time just in case something is out of order.
0 项奖励
回复

1,761 次查看
Shankman
Contributor II

rhinoceroshead wrote:
It looks like the internal clock is selected by default, so maybe this isn't what's happening in your case. But I would still try writing the bits at the same time just in case something is out of order.




You are correct i have stepped through using the BDM and all the right bits are being selected(so it is using the internal clock).

So i am still having the same problem the program enters stop mode and does not exit.. any more ideas why? here is the code below
Thanks

void TxAccel(void)
{
EnableInterrupts;
SOPT_STOPE= 1; /*Enable stop modes*/
SRTISC=0x57;
/* Enable deep sleep mode stop2. */
SPMSC2_PPDC= 1; /* Partial Power Down Control */
SPMSC2_PDC= 1; /* Power Down Control */
TPM1SC = 0x0F; /* Timer divide by 128. (16uS timebase for 8MHz bus clock). */

ATD1PE=0x83; /* enable desired ADC channels (AD0, AD1, AD7 on) */
ATD1C=0xE1; /* set prescale to 4*/

ATD1SC = 0x01; /* read X channel */
while((ATD1SC & 0x80) != 0x80);
gau8TxDataBuffer[1] = ATD1RH;


ATD1SC = 0x00; /* read Y channel */
while((ATD1SC & 0x80) != 0x80);
gau8TxDataBuffer[3] = ATD1RH;


ATD1SC = 0x07; /* read Z channel */
while((ATD1SC & 0x80) != 0x80);
gau8TxDataBuffer[5] = ATD1RH;

gau8TxDataBuffer[0] = 0x78; /* send x */
gau8TxDataBuffer[2] = 0x79; /* send y */
gau8TxDataBuffer[4] = 0x7A; /* send z */
gsTxPacket.u8DataLength = 6;
MCPSDataRequest(&gsTxPacket); /* transmit data */
LED4 ^= 1; /* Toggle LED1 */


STOP(); // linked to asm stop function

delay(0x0FFF);
delay(0x0FFF);
delay(0x0FFF);



} /* end main */
0 项奖励
回复