AnsweredAssumed Answered

Active/Halt wakeup with RTC

Question asked by akbulut.serkan on May 3, 2013
Latest reply on Jun 19, 2013 by ma.wenbing
Hi ,
I am a new user of STM8.  In my project I am using Active/halt mode an it wakes up with RTC Wakeup operation. My problem is, it is always waking up same times. it's equal to 3ms. I want update auto wake up times. 

I am trying to change RTC_SetWakeUpCounter(30000) but it is not setting wake up times. How can ı change wake up times.
Thank you for your comments.

Here is the example code;

///////////////////////////////////////////////////////////////////
#include "stm8l15x.h"
#include "stm8l151f3.h"


#define ENABLE                         1
#define DISABLE                         0


void RTC_Config(void)
{
     RTC_WriteProtectionCmd(DISABLE);
       CLK_RTCClockConfig(CLK_RTCCLKSource_LSI, CLK_RTCCLKDiv_1);
     while (CLK_GetFlagStatus(CLK_FLAG_LSIRDY) == RESET);
       CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
       RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div2);
       RTC_ITConfig(RTC_IT_WUT, ENABLE);
       enableInterrupts();
}
void GPIO_LowPower_Config(void)
{
      GPIO_Init(GPIOA, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);


   GPIO_Init(GPIOB, GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_7, GPIO_Mode_Out_PP_Low_Slow);


   GPIO_Init(GPIOB, GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5, GPIO_Mode_Out_PP_High_Slow);


   GPIO_Init(GPIOC, GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6, GPIO_Mode_Out_PP_Low_Slow);


   GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);


   GPIO_Init(GPIOE, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);


   GPIO_Init(GPIOF, GPIO_Pin_All, GPIO_Mode_Out_PP_Low_Slow);
}


void Halt_Init(void)
{




   PWR_PVDCmd(DISABLE);


   /* Switch to LSI as system clock source */
   /* system clock prescaler: 1*/
   CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
   CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_LSI);
   CLK_SYSCLKSourceSwitchCmd(ENABLE);


   while (CLK_GetFlagStatus(CLK_FLAG_LSIRDY) == 0);
   CLK_HSICmd(DISABLE);
   CLK_HSEConfig(CLK_HSE_OFF);


   /* Set STM8 in low power */
   PWR_UltraLowPowerCmd(ENABLE);
  
   /* Set GPIO in low power*/    
   GPIO_LowPower_Config();
  
   /* Stop RTC Source clock */
     RTC_WriteProtectionCmd(DISABLE);
     RTC_Config();
          RTC_WriteProtectionCmd(DISABLE);
CFG_GCR&=0xFD;
     RTC_SetWakeUpCounter(30000);
  RTC_WakeUpCmd(ENABLE);
     


   CLK_PeripheralClockConfig(CLK_Peripheral_LCD, DISABLE);
}


void main(void)
{
     Halt_Init();
     halt();


while(1)
{
//GPIO_ToggleBits(GPIOB,GPIO_Pin_0);


}
}


/////////////////////////////////////////////////////////////


Outcomes