久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 7560|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

stm32l053r8t6的時(shí)鐘喚醒程序解析

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:98924 發(fā)表于 2015-12-9 01:18 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
  當(dāng)你學(xué)習(xí)stm32l053r8t6這款芯片時(shí),必定要用到他的低功耗功能,所以進(jìn)入低功耗模式是必須要學(xué)習(xí)一下的。
        官方例程如下
        int main(void)
{
  /* STM32L0xx HAL library initialization:
       - Configure the Flash prefetch, Flash preread and Buffer caches
       - Systick timer is configured by default as source of time base, but user
             can eventually implement his proper time base source (a general purpose
             timer for example or other time source), keeping in mind that Time base
             duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
             handled in milliseconds basis.
       - Low Level Initialization
     */
  HAL_Init();

  /* Configure LED2 */
  BSP_LED_Init(LED2);

  /* Configure the system clock to 2 MHz */
  SystemClock_Config();

  /* Configure the system power */
  SystemPower_Config();

  /* Check and handle if the system was resumed from StandBy mode */
  if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET)
  {
    /* Clear Standby flag */
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
  }
  
  /* Insert 5 seconds delay */
  HAL_Delay(5000);
  
    /*The Following Wakeup sequence is highly recommended prior to each Standby mode entry
     mainly  when using more than one wakeup source this is to not miss any wakeup event.
       - Disable all used wakeup sources,
       - Clear all related wakeup flags,
       - Re-enable all used wakeup sources,
       - Enter the Standby mode.
     */
  /*Disable all used wakeup sources*/
  HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle);
  
  /*Re-enable all used wakeup sources*/
    /*## Setting the Wake up time ############################################*/
  /*  RTC Wakeup Interrupt Generation:
      Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI))
      Wakeup Time = Wakeup Time Base * WakeUpCounter
                  = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter
      ==> WakeUpCounter = Wakeup Time / Wakeup Time Base

      To configure the wake up timer to 4s the WakeUpCounter is set to 0x1FFF:
        RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16
        Wakeup Time Base = 16 /(~39.000KHz) = ~0,410 ms
        Wakeup Time = ~4s = 0,410ms  * WakeUpCounter
        ==> WakeUpCounter = ~4s/0,410ms = 9750 = 0x2616 */
   HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, 0x2616, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

  /*Clear all related wakeup flags*/
  __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

  /*Enter the Standby mode*/
  HAL_PWR_EnterSTANDBYMode();

  while (1)
  {
  }
}
上邊的例子展示了系統(tǒng)是如何進(jìn)入休眠模式的。以及如何被RTC喚醒的通過(guò)外部的引腳20來(lái)產(chǎn)生觸發(fā)事件。例子還說(shuō)明了如何進(jìn)入rtc功耗的休眠模式。
        軟件配置成2Mhz.系統(tǒng)滴答每1ms中斷,低速時(shí)鐘LSI被用做RTC。
        20引腳每4s產(chǎn)生一個(gè)上升沿來(lái)喚醒。
        從休眠模式中喚醒后,程序就相當(dāng)于復(fù)位后的重啟,也不用再配置RTC,


注意:例子不能在調(diào)試模式下運(yùn)行,是因?yàn)镸O+核不在狀態(tài)中在低功耗模式下,所以被禁止了。
核會(huì)被占用,當(dāng)如下配置后。
      
@note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
       the RTC clock source; in this case the Backup domain will be reset in  
       order to modify the RTC Clock source, as consequence RTC registers (including
       the backup registers) and RCC_CSR register are set to their reset values.
      
@note Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds)
       based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from
       a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower)
       than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
       To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.
      
@note The application need to ensure that the SysTick time base is always set to 1 millisecond
       to have correct HAL operation.

@par Directory contents
用到的文件目錄
  - PWR/PWR_STANDBY_RTC/Inc/stm32l0xx_conf.h     Library Configuration file
  - PWR/PWR_STANDBY_RTC/Inc/stm32l0xx_it.h       Header for stm32l0xx_it.c
  - PWR/PWR_STANDBY_RTC/Inc/main.h               header file for main.c
  - PWR/PWR_STANDBY_RTC/Src/system_stm32fl0xx.c   STM32L0xx system clock configuration file
  - PWR/PWR_STANDBY_RTC/Src/stm32l0xx_it.c       Interrupt handlers
  - PWR/PWR_STANDBY_RTC/Src/main.c               Main program
  - PWR/PWR_STANDBY_RTC/Src/stm32l0xx_hal_msp.c  HAL MSP module

@par Hardware and Software environment

  - This example runs on STM32L051xx, STM32L052xx, STM32L053xx STM32L062xx and
    STM32L063xx device lines RevZ Rev A.
   
  - This example has been tested with STMicroelectronics STM32L053R8-Nucleo board Rev C
    and can be easily tailored to any other supported device and development board.

  - STM32L053R8-Nucleo Set-up
    - Use LED2 connected to PA.05 pin
    - Connect an amperemeter to JP6 to measure the IDD current

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 国产欧美日韩在线播放 | 亚洲色片网站 | 久热精品在线播放 | 国产精品美女一区二区三区 | 亚洲精品1 | 日韩在线观看 | 蜜桃视频在线观看www社区 | 欧美精品一二三 | 午夜精品久久久 | 一区二区三区精品 | 九九av| 久久99精品久久久久久琪琪 | 日韩欧美在线观看一区 | 亚洲人人 | 四虎国产 | 91亚洲精品在线观看 | 99在线精品视频 | 午夜色婷婷 | 中文字幕av第一页 | 99精品亚洲国产精品久久不卡 | 久久av一区二区三区 | 色综合视频在线 | 国产精品久久国产精品 | 日韩在线视频一区二区三区 | 视频1区| 99pao成人国产永久免费视频 | 成人欧美一区二区三区黑人孕妇 | 精品国产精品国产偷麻豆 | 国产高清在线精品一区二区三区 | 亚洲视频一区二区三区四区 | 精品免费国产视频 | 国产一区二 | 美女视频久久 | 福利视频网 | 青青久草| 亚洲天堂影院 | 视频在线日韩 | 国产精品久久久久久久午夜 | 国产一区免费 | 午夜一区二区三区在线观看 | 亚洲aⅴ一区二区 |