/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************************
* File Name : readme.txt
* Author : MCD Application Team
* Version : V2.0.3
* Date : 09/22/2008
* Description : Description of the PWR STOP Example.
********************************************************************************************/
Example description 例程描述 经修改适用于万利STM3210B-LK1,翻译后有对应接口变动
===================
This example shows how to enter the system to STOP mode and wake-up using EXTI Line interrupts. The EXTI Line sources are PB.09/PG.08 and RTC Alarm.
这个例子描述了如何进入停机模式和如何使用中断线唤醒停机模式。中断线是PD3(EXTI_Line3)和RTC闹钟(EXTI_Line17)
The EXTI line9/8 is configured to generate interrupt on falling edge.
中断线EXTI_Line3被配置在下降沿产生中断
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
The EXTI line17(RTC Alarm) is configured to generate interrupt on rising edge and the RTC time base is set to 1 second using the external low speed oscillator(LSE).
RTC闹钟被配置在上升沿产生中断,这里RTC时基被设置为1秒,使用外部低速外部晶振LSE
The system clock is set to 72 MHz using the external high speed oscillator(HSE).
系统时钟被为72MHZ,使用高速外部晶振HSE
系统进入和退出停机模式按如下方式:
The system enters and exits STOP mode as following:
After 2 second from system start-up, the RTC is configured to generate an Alarm event in 3 second then the system enters STOP mode. To wake-up from STOP mode you have to apply a falling
edge on EXTI line9/8, otherwise the RTC Alarm will wake-up the system within 3 second. After exit from STOP the system clock is reconfigured to its previous state (as HSE and PLL are disabled in STOP mode).Then after a delay the system will enter again in STOP mode and exit in the way described above. This behavior is repeated in an infinite loop.
在系统启动后2秒,RTC被配置3秒后产生警报事件然后进入停机模式。如果要从停机模式唤醒,需在中断线EXTI_Line3配置下降沿,否则RTC报警将在3秒内唤醒系统。从停机模式退出后系统时钟要重新配置(因为HSE,PLL振荡器的功能被禁用)。然后将会有一段额外的启动延时,紧接着又进入停机模式,无限循环。
- /*******************************************************************************
- * Function Name : SYSCLKConfig_STOP
HSE,PLL重新配置
- * Description : Configures system clock after wake-up from STOP: enable HSE, PLL
- * and select PLL as system clock source.
- * Input : None
- * Output : None
- * Return : None
- *******************************************************************************/
- void SYSCLKConfig_STOP(void)
- {
- /* Enable HSE */
- RCC_HSEConfig(RCC_HSE_ON);
- /* Wait till HSE is ready */
- HSEStartUpStatus = RCC_WaitForHSEStartUp();
- if(HSEStartUpStatus == SUCCESS)
- {
- /* Enable PLL */
- RCC_PLLCmd(ENABLE);
- /* Wait till PLL is ready */
- while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
- {
- }
- /* Select PLL as system clock source */
- RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
- /* Wait till PLL is used as system clock source */
- while(RCC_GetSYSCLKSource() != 0x08)
- {
- }
- }
- }
注意:万利的板子PC7--LED1 PC6--LED2 PC5--LED3 PC4---LED4 KEY2--PD4
Four leds connected to GPIO_LED Pin6(LD1), Pin7(LD2) and Pin8(LD3) are used to monitor the system state as following:
- LD1 on: system in RUN mode LD1灯亮表示系统处在运行模式
- LD1 off: system in STOP mode LD1灭表示系统处在停机模式
- LD2 is toggled if EXTI Line9/8 is used to exit from STOP 按KEY2后LD2翻转表示从停机模式退出
- LD3 is toggled if EXTI line17(RTC Alarm) is used to exit from STOP
RTC警报触发后LD3翻转表示从停机模式退出
******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE******
阅读(2421) | 评论(0) | 转发(1) |