cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 reset when wakeup by extern line from stop mode

jason_17
Associate II
Posted on May 23, 2013 at 18:16

Hello, everybody

now I use stm32f103r8, I haved followed the reference manual and configured my mcu in to stop mode. And it has been in stopmode, but when i press button to wakeup the mcu, the mcu reset. I print value of register RCC_CSR, it's the default value 0x0c000000.

as descriped above, my problem is why mcu reset when I pressed button to wakeup the mcu?

by the way, I post my code below:

void MCU_sleep (void)

{

    UART1_send_array ((u8 *)''go to sleep\r\n'', 13); //debug  

    AFIO -> EXTICR[0] = 0 << 12; //exit_lin3 enable

    AFIO -> EXTICR[2] = 0 << 0;  //exit_lin8 enable

    

    EXTI -> IMR = (1 << 3) | (1 << 8); //exit interrupt mode  

    EXTI -> FTSR = (1 << 3) | (1 << 8); //rising edge trigger

      

    //clr pending request and rtc flag before enter stop

    EXTI -> PR = (1 << 3) | (1 << 8);

    RTC -> CRL &= (~(1 << 1)); //clr RTC alarm flag

 

    //set SLEEP_DEEP bit(2), clr SEVEONPEND bit(4)

    SCB -> SCR |= (1 << 2); 

    //clr PDDS bits in PWR_CR, means sleep mode

    PWR -> CR &= (~(1 << 1)); 

    //LPDS(bit0) = 0

    PWR -> CR &= (~(1 << 0)); //regulator on during sleep mode

    WFI_SET();

    //clr SLEEP_DEEP bit after wakeup

    SCB -> SCR &= (~((1 << 2)));

    RTC -> CRL &= (~(1 << 1));       

    //after wakeup, configure clock again

    RCC_config ();

    UART1_send_array ((u8 *)''wake up\r\n'', 9); 

}

void interrupt_config (void)

{

    //EXIT3, position 9?priority 16

    //EXIT8?position 23? priority 30

    //ISER?interrupt enable

    NVIC -> ISER[0] = (1 << 9) | (1 << 23); 

}

the debug information by uart descrip below:

power on

RCC_CSR=0x0C000000

UART1 test                 

go to sleep                   //mcu sleep here, and I press button, mcu reset, 

power on

RCC_CSR=0x0C000000

UART1 test

go to sleep

#forum-says-no #stm32-stop-mode-reset
6 REPLIES 6
jason_17
Associate II
Posted on May 24, 2013 at 03:41

can anybody give some advice? it's so strange, but I have checked the code many times. however, i still can not work. why?

frankmeyer9
Associate II
Posted on May 24, 2013 at 10:59

Do you have a handler for the EXTI interrupts you configured & enabled ?

jason_17
Associate II
Posted on May 24, 2013 at 11:45

hi, fm

thanks for your reply! I am sure have done it.

Posted on May 24, 2013 at 12:54

can anybody give some advice?

Sorry, debugging other people's register level code simply doesn't interest me.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
frankmeyer9
Associate II
Posted on May 24, 2013 at 14:18

Sorry, debugging other people's register level code simply doesn't interest me.

 

Me too.

That seems to be another, secondary disadvantage of register-level coding ...

jason_17
Associate II
Posted on May 24, 2013 at 16:23

everyboy, thanks for attention!

The problem have been resolved!

it's caused by the function WRI_SET()