cancel
Showing results for 
Search instead for 
Did you mean: 

problem with leaving from standby mode

kkkuba
Associate II
Posted on July 26, 2013 at 12:06

Hi, i've got a problem with leaving from standby mode, both by RTC Alarm and WKUP pin. This is my code:

int

main(

void

)

{

#ifdef DEBUG

debug();

#endif

prvSetupHardware();

GPIOC->ODR |= (u16)0x0040;

PWR_EnterSTANDBYMode();

GPIOC->ODR &= (u16)~0x0040; while

(1) {};

}

static

void

prvSetupHardware(

void

)

{

RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC

| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE );

NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 );

NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );

vLedInitialise();

vEXTI_Configuration();

vNVIC_Configuration();

vRTC_Configuration(); PWR_WakeUpPinCmd(ENABLE);

}

void

vEXTI_Configuration(

void

)

{

EXTI_InitTypeDef EXTI_InitStructure;

/* Configure EXTI Line17(RTC Alarm) to generate an interrupt on rising edge */

EXTI_ClearITPendingBit(EXTI_Line17);

EXTI_InitStructure.EXTI_Line = EXTI_Line17;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

EXTI_InitStructure.EXTI_LineCmd = ENABLE;

EXTI_Init(&EXTI_InitStructure);

}

/*-----------------------------------------------------------*/

void

vNVIC_Configuration(

void

)

{

NVIC_InitTypeDef NVIC_InitStructure;

/* Configure one bit for preemption priority */

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

/*Enable the RTC Alarm Interrupt*/

NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

}

/*-----------------------------------------------------------*/

void

vRTC_Configuration(

void

)

{

RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

/* Allow access to BKP Domain */

PWR->CR |= 0x00000100;

RCC_LSEConfig(RCC_LSE_ON);

while

(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {}

RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);

RCC_RTCCLKCmd(ENABLE);

RTC_WaitForSynchro();

RTC_WaitForLastTask();

RTC_ITConfig(RTC_IT_ALR, ENABLE);

RTC_WaitForLastTask();

RTC_SetPrescaler(32767);

RTC_WaitForLastTask();

while

( RTC_GetFlagStatus( RTC_FLAG_SEC ) == RESET ) {}

RTC_SetAlarm(5);

RTC_WaitForLastTask();

}

void

RTCAlarm_IRQHandler(

void

)

{

GPIOC->ODR ^= 0x00000080;

EXTI_ClearITPendingBit(EXTI_Line17);

if

(PWR_GetFlagStatus(PWR_FLAG_WU) != RESET) PWR_ClearFlag(PWR_FLAG_WU);

RTC_WaitForLastTask();

RTC_ClearITPendingBit(RTC_IT_ALR);

RTC_WaitForLastTask();

}

I know that EXTI isn't necessary to wake MCU up from standby mode, but I tried the same code with Stop Mode and it works.

Another issue is strange operation with debugger (JLINK) connected to the eval board - with Stop mode I had to abort debug session, and reset MCU. In standby mode I tried with connected or disconnected debugger and it has never worked.

Could anyone help me?

Regards

#stm32-standby-wake-rtc #wkup

2 REPLIES 2
Posted on July 26, 2013 at 13:29

What part is this with?

Do you enable the GPIO pins somewhere?

Generally you're not going to be able to use hardware debugging to function across events that power down the core. You need to change your testing to output diagnostic/telemetry information via a serial port.

When you reset you don't want to mess with the full RTC setup if this is a STANDBY RESET, look at some of the PWR\STANDBY project examples

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kkkuba
Associate II
Posted on July 26, 2013 at 13:41

Thanks for reply. I use STMF103. Problem with WKUP pin is solved - simply on my eval board this pin is connected to Vcc via a series resistor. When I shorted it to ground then forced MCU to get into standby mode and connect pin to Vcc - MCU waked up. But with RTC it still doesn't work (I tested it with WKUP pin shorted to ground).

Yes, I know that after reset I don't need to reconfigure RTC from scratch