Chinaunix首页 | 论坛 | 博客
  • 博客访问: 132365
  • 博文数量: 64
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2014-04-26 18:44
文章分类

全部博文(64)

文章存档

2014年(64)

我的朋友

分类: C/C++

2014-04-26 19:05:28

原文地址:PWR停机模式文件描述 作者:

/******************** (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振荡器的功能被禁用)。然后将会有一段额外的启动延时,紧接着又进入停机模式,无限循环。

点击(此处)折叠或打开

  1. /*******************************************************************************
  2. * Function Name : SYSCLKConfig_STOP  HSE,PLL重新配置
  3. * Description : Configures system clock after wake-up from STOP: enable HSE, PLL
  4. * and select PLL as system clock source.
  5. * Input : None
  6. * Output : None
  7. * Return : None
  8. *******************************************************************************/
  9. void SYSCLKConfig_STOP(void)
  10. {
  11.   /* Enable HSE */
  12.   RCC_HSEConfig(RCC_HSE_ON);

  13.   /* Wait till HSE is ready */
  14.   HSEStartUpStatus = RCC_WaitForHSEStartUp();

  15.   if(HSEStartUpStatus == SUCCESS)
  16.   {
  17.     /* Enable PLL */
  18.     RCC_PLLCmd(ENABLE);

  19.     /* Wait till PLL is ready */
  20.     while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
  21.     {
  22.     }

  23.     /* Select PLL as system clock source */
  24.     RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

  25.     /* Wait till PLL is used as system clock source */
  26.     while(RCC_GetSYSCLKSource() != 0x08)
  27.     {
  28.     }
  29.   }
  30. }
注意:万利的板子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******

阅读(820) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~