cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get PWR_EnterSTOPMode to work - help!!

jdmallett
Associate II
Posted on June 27, 2008 at 17:59

Can't get PWR_EnterSTOPMode to work - help!!

8 REPLIES 8
jdmallett
Associate II
Posted on May 17, 2011 at 12:36

Hi,

I have been banging my head for weeks trying to get the low power stop mode working in the STM32. I am using the PWR_EnterSTOPMode(PWR_Regulator_ON, PWR_STOPEntry_WFE) command and have also tried using PWR_STOPEntry_WFI with no success.

My hardware is the STM32-EVAL board from ST and a Raisonance RLink Pro debugger. When I'm either in debug mode or running with the RLink disconnected it seems to hang at the above command.

Is there a problem with this library function? Has anyone else had any issues with using the STOP mode?

Any help would be very much welcomed!

James

[ This message was edited by: jdmallett on 04-06-2008 15:30 ]

jdmallett
Associate II
Posted on May 17, 2011 at 12:36

Can anyone help with my problem...? :-[

joseph239955
Associate II
Posted on May 17, 2011 at 12:36

Hi James,

Could you put more details?

Can debugger still able to halt the core and

access registers? or completely no response?

Have you try replace the sleep command with a

loop and see if interrupt can take place?

(to check if the interrupt is setup correctly?)

regards,

Joseph

jdmallett
Associate II
Posted on May 17, 2011 at 12:36

Hello Joseph, thanks for the reply.

I have tried a while loop and it the interrupt/event does take place. I can use the _WFE() or _WFI() with success, although the power is not very low.

However in stop mode the debugging halts at the PWR_EnterSTOPMode function. I can single step through this, but when I run it just halts at this function. I am using RTC_Second to generate an event.

I have followed the low power examples but I must be doing something wrong...

James

kelly2
Associate II
Posted on May 17, 2011 at 12:36

James,

This is an duplicitive error. It only needs to be called once to activate the NVIC Alarm channel. Thanks!

It sounds like you ARE entering STOP, but not comming back out. I have not used the event style in any code, sorry I cannot help you there. But if you switch your events over to interrupts and use the RTC_ALARM to generate a wakup, it works. If you switch to interrupts soley then this, ''NVIC_SystemLPConfig(NVIC_LP_SEVONPEND, ENABLE);'',

is not needed.

The ''NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQChannel;'' Will not come through the EXTI line 17.

Here is some RTC ALARM Code I have:

CODE TO ENABLE ACCESS TO BACKUP DOMAIN:

RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_PWR, ENABLE);

//Recommend do both and keep both clocks gated

CODE TO SET ALARM:

//This assumes that your RTC is already setup to Tick at 1 sec

RTC_WaitForLastTask(); /* Wait until last write operation on RTC */

RTC_SetAlarm(RTC_GetCounter()+2); //Wakeup in 2 seconds

RTC_WaitForLastTask(); /* Wait until last write operation on RTC */

RTC_ClearFlag(RTC_FLAG_ALR);

RTC_WaitForLastTask(); /* Wait until last write operation on RTC */

RTC_ITConfig(RTC_IT_ALR,ENABLE);

RTC_WaitForLastTask(); /* Wait until last write operation on RTC */

INTERRUPT CODE:

void RTCAlarm_IRQHandler(void){

if(RTC_GetITStatus(RTC_IT_ALR) != RESET){

RTC_ITConfig(RTC_IT_ALR,DISABLE);

RTC_WaitForLastTask();

RTC_ClearFlag(RTC_FLAG_ALR);

RTC_WaitForLastTask();

...(any thing you want)...

}

EXTI_ClearITPendingBit(EXTI_Line17);

}

Hope this helps!

Kelly

kelly2
Associate II
Posted on May 17, 2011 at 12:36

Hello James,

I just got my Stop Mode working. I did use the STM32FWLib. It does work. My application actually needs Sleep, Stop, and Standby. I now have them all working together.

Here is what I did to get stop mode working:

First, Interrupt Setup. ONLY EXTI LINES can bring the device back from stop. The only sources for EXTI is I/O, RTC ALARM, USB Wakup, and PVD. So I have the IO and RTC ALARM enabled.

NVIC CONFIGS:

/* Enable the EXTI17/Alarm Channel Interrupt */

NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;

NVIC_Init(&NVIC_InitStructure);

/* Configure EXTI Lines with rising edge detect */

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

EXTI_InitStructure.EXTI_Line = EXTI_Line17; //RTC_Alarm

EXTI_Init(&EXTI_InitStructure);

The Interrupt ''void RTCAlarm_IRQHandler(void)'' needs

if(RTC_GetITStatus(RTC_IT_ALR) != RESET){

RTC_WaitForLastTask();

RTC_ClearFlag(RTC_FLAG_ALR);

RTC_WaitForLastTask();

....

}

EXTI_ClearITPendingBit(EXTI_Line17);

ENTRY:

PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFI);

//Any compination of WFI I have tested and it works

EXIT: RTC ALARM or EXTI Buttons

when it returns, the HSE/PLL are off so renable if necessary.

also, the SCB->SCR->SLEEPDEEP bit need to be reset! otherwise sleep (WFI) calls will trigger STOP again. That is what I did. I don't have any experience with WFE though. However I read on another forum that the SCB-SCR->SEVONPEND (Send EVent ON PENDING interrupt) bit will wake up the processor from any interrupt. The Lib call ''NVIC_SystemLPConfig(NVIC_LP_SEVONPEND, ENABLE);'' will do that for you.

Good Luck.

PS> An Moderator out there needs to recommend that people using all stop modes needs to reset SCB->SCR->SLEEPDEEP after stop. So Recommend calling ''NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP, DISABLE);''

[ This message was edited by: kelly1 on 27-06-2008 17:48 ]

[ This message was edited by: kelly1 on 27-06-2008 17:51 ]

null

[ This message was edited by: kelly1 on 27-06-2008 20:05 ]

jdmallett
Associate II
Posted on May 17, 2011 at 12:36

Thanks kelly1.

You have repeated the code, is this correct?

/* Enable the RTC ALARM Interrupt */

NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;

NVIC_Init(&NVIC_InitStructure);

/* Enable the EXTI17/Alarm Channel Interrupt */

NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;

NVIC_Init(&NVIC_InitStructure);

Well I have tried PWR_EnterSTOPMode(PWR_Regulator_LowPower,PWR_STOPEntry_WFE); and PWR_EnterSTOPMode(PWR_Regulator_ON,PWR_STOPEntry_WFE); and still no joy, not tried PWR_STOPEntry_WFI yet.

I have also called NVIC_SystemLPConfig(NVIC_LP_SEVONPEND, ENABLE); in NVIC configuration and also NVIC_SystemLPConfig(NVIC_LP_SLEEPDEEP, DISABLE); straight after the EnterSTOPMode function.

I am not using the HSE so I don't enable this.

One thing I have noticed is that I was originally using

NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQChannel;

Will this interrupt source not work through the EXTI line interrupt, or do I have to use RTCAlarm_IRQChannel?

I can still step through the code, but it will not run, it still halts at the PWR_EnterSTOPMode function.

I could really do with an RTC low power example specifically for Ride7 to see how it's done.

James

jdmallett
Associate II
Posted on May 17, 2011 at 12:36

Thanks for that Kelly, I have got it working with interrupts using PWR_STOPEntry_WFI.

However you may be able to help further.

The RTC can generate three interrupts from the backup domain: RTC_Second, RTC_Overflow and RTC_Alarm. I would ideally like to use RTC_Second as I am sampling an external signal at a particular rate and this gives me the best sampling. Also I don't need to reload RTC_CNT or RTC_ALR which saves a bit of time.

Does the RTCAlarm_IRQHandler(void) interrupt handler only work with RTC_Alarm as the interrupt source, or can you use RTC_Second or RTC_Overflow? Can they all be treated as EXTI17 interrupts? In the AN2629 RTC application note it shows them all OR-ed together, but I have been unable to get the above IRQ to trigger when using RTC_Second.

Any advice would be gratefully welcomed!

James