打印

关于低功耗的问题

[复制链接]
1499|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
dmj2168|  楼主 | 2013-4-1 08:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我的问题是现在时钟报警可以了,但是进入STOP模式之后,程序从在线跳出来了,但是我发现程序并没有停在STOP模式的进入语句里,而是向下执行了,因为后面跳出开系统时钟的语句后面我加的让小灯点亮的语句执行了,小灯亮了,那是怎么回事呢,我贴出我的这部分程序,求高手指点哈,我的是这样的,收到GPS(串口3)数据写入SRAM,判断是不是要写入SD卡,要就写入,不要就继续执行。给报警加载时间60S然后进入STOP模式,等待报警唤醒。

相关帖子

沙发
dmj2168|  楼主 | 2013-4-1 09:05 | 只看该作者
int main()
{
        #ifdef DEBUG
        debug();
        #endif
        Configuration();
        deletef("cmd.dat");                
        creatf("cmd.dat",0,0);
        GPIO_SetBits(GPIOB, GPIO_Pin_12);                            //给GPS供电打开
        USART_ITConfig(USART3,USART_IT_RXNE  , ENABLE);
        Delay1(30000);               
        while(1)
        {  
           GPSdataformat();                                                                                         //用串口收到GPS数据,并且写入 SRAM

           if(count>400)
           {
               writef("cmd.dat",GPS,count);                                                   //写入SD卡SRAM的数据
               Delay1(100);
                   count=0;
           }
           else
           {
               Delay1(100);
           }
           //Delay1(5500);
           RTC_ClearFlag(RTC_FLAG_SEC);
       while(RTC_GetFlagStatus(RTC_FLAG_SEC) == RESET);

       /* Alarm in 3 second */
       RTC_SetAlarm(RTC_GetCounter()+ 60);
       /* Wait until last write operation on RTC registers has finished */
       RTC_WaitForLastTask();       
          // RCC_ClearFlag();                         
           if (dingwei==0)
           {
               PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
           SYSCLKConfig_STOP();       
                   Delay1(2000);                  
           }
          }
}

/*******************************************************************************
* Function Name  : PWR_EnterSTOPMode
* Description    : Enters STOP mode.
* Input          : - PWR_Regulator: specifies the regulator state in STOP mode.
*                    This parameter can be one of the following values:
*                       - PWR_Regulator_ON: STOP mode with regulator ON
*                       - PWR_Regulator_LowPower: STOP mode with
*                         regulator in low power mode
*                  - PWR_STOPEntry: specifies if STOP mode in entered with WFI or
*                    WFE instruction.
*                    This parameter can be one of the following values:
*                       - PWR_STOPEntry_WFI: enter STOP mode with WFI instruction
*                       - PWR_STOPEntry_WFE: enter STOP mode with WFE instruction
* Output         : None
* Return         : None
*******************************************************************************/
void PWR_EnterSTOPMode(u32 PWR_Regulator, u8 PWR_STOPEntry)
{
  u32 tmpreg = 0;

  /* Check the parameters */
  assert_param(IS_PWR_REGULATOR(PWR_Regulator));
  assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry));
  
  /* Select the regulator state in STOP mode ---------------------------------*/
  tmpreg = PWR->CR;

  /* Clear PDDS and LPDS bits */
  tmpreg &= CR_DS_Mask;

  /* Set LPDS bit according to PWR_Regulator value */
  tmpreg |= PWR_Regulator;

  /* Store the new value */
  PWR->CR = tmpreg;

  /* Set SLEEPDEEP bit of Cortex System Control Register */
  *(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPDEEP_Set;
  
  /* Select STOP mode entry --------------------------------------------------*/
  if(PWR_STOPEntry == PWR_STOPEntry_WFI)
  {   
    /* Request Wait For Interrupt */
    __WFI();
  }
  else
  {
    /* Request Wait For Event */
    __WFE();
  }
}


/*******************************************************************************
* Function Name  : RTCAlarm_IRQHandler
* Description    : This function handles RTC Alarm interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void RTCAlarm_IRQHandler(void)

{
  if(RTC_GetITStatus(RTC_IT_ALR) != RESET)
  {
    /* Clear EXTI line17 pending bit */
    EXTI_ClearITPendingBit(EXTI_Line17);

    /* Check if the Wake-Up flag is set */
    if(PWR_GetFlagStatus(PWR_FLAG_WU) != RESET)
    {
      /* Clear Wake Up flag */
      PWR_ClearFlag(PWR_FLAG_WU);
    }

    /* Wait until last write operation on RTC registers has finished */
    RTC_WaitForLastTask();   
    /* Clear RTC Alarm interrupt pending bit */
    RTC_ClearITPendingBit(RTC_IT_ALR);
    /* Wait until last write operation on RTC registers has finished */
    RTC_WaitForLastTask();
        USART_ITConfig(USART3,USART_IT_RXNE  , ENABLE);
        GPIO_SetBits(GPIOB, GPIO_Pin_12);                            //给GPS供电打开
  }
}


使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

15

帖子

1

粉丝