2013-05-23 09:16 AM
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 onRCC_CSR=0x0C000000UART1 test go to sleep //mcu sleep here, and I press button, mcu reset, power onRCC_CSR=0x0C000000UART1 testgo to sleep #forum-says-no #stm32-stop-mode-reset2013-05-23 06:41 PM
can anybody give some advice? it's so strange, but I have checked the code many times. however, i still can not work. why?
2013-05-24 01:59 AM
Do you have a handler for the EXTI interrupts you configured & enabled ?
2013-05-24 02:45 AM
hi, fm
thanks for your reply! I am sure have done it.2013-05-24 03:54 AM
can anybody give some advice?
Sorry, debugging other people's register level code simply doesn't interest me.2013-05-24 05:18 AM
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 ...
2013-05-24 07:23 AM
everyboy, thanks for attention!
The problem have been resolved!it's caused by the function WRI_SET()