你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

stm8 定时唤醒时第一次运行有延时

[复制链接]
cdm 提问时间:2021-8-31 17:21 /
各位大佬好!我最近就做一个STM8L定时唤醒,STM8L050程序调用RTC_WakeUpCmd(DISABLE)语句,就进WUTWF标志超时,导致上电第一次有一个很大延时后面程序能正常运行,用的官方STM8的函数库
程序卡在下面这个while里面超时后退出导致第一次运行有一个很大的延时
    /* Wait until WUTWF flag is set */
    while (((RTC->ISR1 & RTC_ISR1_WUTWF) == RESET) && ( wutwfcount != WUTWF_TIMEOUT))
    {
      //wutwfstatus = (uint8_t)(RTC->ISR1 & RTC_ISR1_WUTWF);
      wutwfcount++;
    }

以下是部分代码:
void RTC_Config(void)
{   
    //RTC_DeInit();
    /* Enable RTC clock */
    CLK_RTCClockConfig(CLK_RTCCLKSource_LSI,CLK_RTCCLKDiv_1);//RTC Clock Source Selection
    /* Enable RTC clock */        
    CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);//使能RTC的时钟   
    /* Configures the RTC wakeup timer_step = RTCCLK/16 = 1/38K/16 = 1644.7368 us */
    RTC_WakeUpClockConfig(RTC_WakeUpClock_CK_SPRE_16bits);
    /* Enable wake up unit Interrupt */
    RTC_ITConfig(RTC_IT_WUT, ENABLE);
    /* Enable general Interrupt*/
    enableInterrupts();  
}


void Delay(__IO uint16_t nCount)
{
  /* Decrement nCount value */
  while (nCount != 0)
  {
    nCount--;
    nop();nop();nop(); nop();nop();nop();
  }

}
void main(void)
{  
   CLK_Config();   
   Delay(10000);     
Begin:
   /* CLK configuration -------------------------------------------*/
   CLK_Config();
   PWR_UltraLowPowerCmd(ENABLE);/* */
/* RTC configuration -------------------------------------------*/                  
   RTC_Config();   
   //RTC_ClearFlag(RTC_FLAG_WUTWF);
     /* TIM2 configuration -------------------------------------------*/
    //TIM2_Config();   
   GPIO_Init(GPIOB, GPIO_Pin_6, GPIO_Mode_Out_PP_Low_Fast);  
  while (1)
  {
  /* Enter Wait for interrupt mode*/   
   //  wfi();  
    //  GPIO_ToggleBits(GPIOB, GPIO_Pin_6);
   GPIO_SetBits(GPIOB, GPIO_Pin_6);
   Delay(1000);//500ms
   GPIO_ResetBits(GPIOB, GPIO_Pin_6);

   RTC_SetWakeUpCounter(1);//
   RTC_WakeUpCmd(ENABLE);
   //GPIO_Init(GPIOA, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Fast);
   //GPIO_ResetBits(GPIOA, GPIO_Pin_All);
   //GPIO_Init(GPIOB, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Fast);
  // GPIO_ResetBits(GPIOB, GPIO_Pin_All);   
  // GPIO_Init(GPIOC, GPIO_Pin_0 , GPIO_Mode_Out_PP_Low_Fast);//| GPIO_Pin_6
  // GPIO_ResetBits(GPIOC, GPIO_Pin_0 | GPIO_Pin_6);  
  // GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Fast);
  // GPIO_ResetBits(GPIOD, GPIO_Pin_All);   

   /* 4. Configure Flash & EEPROM in IDDQ mode while WAIT mode */
   //FLASH_PowerWaitModeConfig(FLASH_Power_IDDQ);   

    halt();
    RTC_WakeUpCmd(DISABLE);
   goto Begin;
  }
}

STM8programV5.3.rar

下载

7.32 MB, 下载次数: 0, 下载积分: ST金币 -1

收藏 评论3 发布时间:2021-8-31 17:21

举报

3个回答
magee 回答时间:2021-8-31 23:03:05
学习
butterflyspring 回答时间:2021-9-1 11:36:09
建议在RTC_Config(); 前面加上一行 RTC_WakeUpCmd(DISABLE);  试试。
cdm 回答时间:2021-9-2 14:52:23
butterflyspring 发表于 2021-9-1 11:36
建议在RTC_Config(); 前面加上一行 RTC_WakeUpCmd(DISABLE);  试试。

试了,还是有延时

所属标签

相似问题

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版