cancel
Showing results for 
Search instead for 
Did you mean: 

How to keep date and time after shut down power in STM32F429iDisco?

Linda
Associate II
Posted on June 10, 2015 at 23:34

Hi,

We want to add a cell battery to keep time and date. but in the schemaitcs, Pin 1 and Pin 6 in STM32F429iDisco for VBAT alredy connect to +3V.

What we can do?

Thanks a lot
23 REPLIES 23
Posted on June 11, 2015 at 16:20

See UM1670, 4.11.2 OSC 32 KHz clock supply, ''Oscillator on board (from X2 Crystal)''

JW

Posted on June 11, 2015 at 16:37

Yes, PC14/15, needs to be a 6pF crystal, check the BOM

ST commonly uses the EPSON 32.768KHz 6pF part (formerly JFVNY)

http://uk.mouser.com/ProductDetail/Epson-Timing/MC-306-327680K-E3ROHS/?qs=CU9taR8hkvbntLhqKVy/5g%3D%3D

You should review thoroughly the available documentation, or have your design engineer do so.

6.8pF capacitors at C23,C24

0 Ohm resistors at R53, R54

Open SB16,SB17

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Linda
Associate II
Posted on June 12, 2015 at 02:57

Dear Sir,

I have soldered those parts on the PCB, but no matter I open or close SB 16 and SB17, the time has not been updated.

What is wrong? Do I need to do anything in coding/program? Why I need to open SB16/SB17, after open them, the crystal connects to no where.

Thanks

Posted on June 12, 2015 at 05:13

Doesn't the SB just disconnect the STM32 from the pin header? This is done so the leads to the crystal a very short.

You should enable the LSE, and check that it starts and oscillates correctly.

You would need to select it as a source for the RTC.

You'd need to place the device in STANDBY, and make sure the code detects a reset out of standby, and not completely reinitialize the RTC. You could set the alarm to periodically exit standby, or use wakeup.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Linda
Associate II
Posted on June 13, 2015 at 14:10

If I put the device on

  standby mode, the LCD is on, it take a lot of battery. how to shut of LCD?

Thanks

Posted on June 13, 2015 at 18:56

It's not designed to do that, you'd need to gate the primary supply at the regulator, probably.

It sounds like you need to design a custom board with the feature set you require.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Linda
Associate II
Posted on June 14, 2015 at 15:09

I tried to put the device on STOP mode. But it can not wake up. Here is code I use:

int8_t RTC_Configuration(void)

{ RTC_Error = 0;

  EXTI_InitTypeDef  EXTI_InitStructure;

  NVIC_InitTypeDef  NVIC_InitStructure;

   /* Enable the PWR clock */

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

  /* Allow access to RTC */

  PWR_BackupAccessCmd(ENABLE);

#if defined (RTC_CLOCK_SOURCE_LSI)  /* LSI used as RTC source clock*/

/* The RTC Clock may varies due to LSI frequency dispersion. */   

  /* Enable the LSI OSC */ 

  RCC_LSICmd(ENABLE);

  /* Wait till LSI is ready */  

  while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)

  {

  }

  /* Select the RTC Clock Source */

  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

#elif defined (RTC_CLOCK_SOURCE_LSE) /* LSE used as RTC source clock */

  /* Enable the LSE OSC */

  RCC_LSEConfig(RCC_LSE_ON);

  /* Wait till LSE is ready */  

  while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)

  {

  }

  /* Select the RTC Clock Source */

  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);

#else

  #error Please select the RTC Clock source inside the main.c file

#endif /* RTC_CLOCK_SOURCE_LSI */

  /* Enable the RTC Clock */

  RCC_RTCCLKCmd(ENABLE);

  /* Wait for RTC APB registers synchronisation */

  RTC_WaitForSynchro();

  /* RTC Wakeup Interrupt Generation: Clock Source: RTCCLK_Div16, Wakeup Time Base: ~4s

     Wakeup Time Base = (16 / (LSE or LSI)) * WakeUpCounter

  */

  RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);

  RTC_SetWakeUpCounter(0x1FFF);

  /* Enable the Wakeup Interrupt */

  RTC_ITConfig(RTC_IT_WUT, ENABLE);

  /* Connect EXTI_Line22 to the RTC Wakeup event */

  EXTI_ClearITPendingBit(EXTI_Line22);

  EXTI_InitStructure.EXTI_Line = EXTI_Line22;

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

   /* Enable the RTC Wakeup Interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

   /* Calendar Configuration with LSI supposed at 32KHz */

  RTC_InitStructure.RTC_AsynchPrediv = 0x7F;

  RTC_InitStructure.RTC_SynchPrediv =  0xFF; /* (32KHz / 128) - 1 = 0xFF*/

  RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;

  RTC_Init(&RTC_InitStructure);  

  /* Get the LSI frequency:  TIM5 is used to measure the LSI frequency */

  LsiFreq = GetLSIFrequency();

  /* Adjust LSI Configuration */

  RTC_InitStructure.RTC_AsynchPrediv = 0x7F;

  RTC_InitStructure.RTC_SynchPrediv =  (LsiFreq/128) - 1;

  RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;

  RTC_Init(&RTC_InitStructure);

  return RTC_Error;

}

static void SYSCLKConfig_STOP(void)

{  /* After wake-up from STOP reconfigure the system clock */

  /* Enable HSE */

  RCC_HSEConfig(RCC_HSE_ON);

  /* Wait till HSE is ready */

  while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET)

  {

  }

    /* Enable PLL */

  RCC_PLLCmd(ENABLE);

   /* Wait till PLL is ready */

  while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)

  {

  }

    /* Select PLL as system clock source */

  RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

  /* Wait till PLL is used as system clock source */

  while (RCC_GetSYSCLKSource() != 0x08)

  {

  }

}

main {

  STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);

  while (1)

  {

    /* Insert 5 second delay */

    GUI_Delay(5000);

    /* Turn OFF LED4 */

    STM_EVAL_LEDOff(LED4);

    /* Enable Wakeup Counter */

    RTC_WakeUpCmd(ENABLE);

    /* Enter Stop Mode */

    PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);

     /* Disable Wakeup Counter */

    RTC_WakeUpCmd(DISABLE);

    /* Configures system clock after wake-up from STOP: enable HSE, PLL and select 

       PLL as system clock source (HSE and PLL are disabled in STOP mode) */

    SYSCLKConfig_STOP();

  }

}
Posted on June 14, 2015 at 16:00

You might want to work on a more linear initialization sequence.

Measure the frequency after the LSI starts, then init the RTC (once), the init the WakeUp (after).

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Linda
Associate II
Posted on June 14, 2015 at 18:03

Check the LED3 and LED4, it seems wake up. just can not go back where it was. 

Then I tried add these code following, then it can not wake up.:

 JumpAddress = *(__IO uint32_t*) (0x08000000 + 4);

 Jump_To_Application = (pFunction) JumpAddress;

 __set_MSP(*(__IO uint32_t*) 0x08000000);

 Jump_To_Application();

It becomce like that, then it can not wake up.

static void SYSCLKConfig_STOP(void)

{

  /* After wake-up from STOP reconfigure the system clock */

  /* Enable HSE */

  RCC_HSEConfig(RCC_HSE_ON);

  

  /* Wait till HSE is ready */

  while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET)

  {

  }

  

  /* Enable PLL */

  RCC_PLLCmd(ENABLE);

  

  /* Wait till PLL is ready */

  while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)

  {

  }

  

  /* Select PLL as system clock source */

  RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);

  

  /* Wait till PLL is used as system clock source */

  while (RCC_GetSYSCLKSource() != 0x08)

  {

  }

 JumpAddress = *(__IO uint32_t*) (0x08000000 + 4);

 Jump_To_Application = (pFunction) JumpAddress;

 __set_MSP(*(__IO uint32_t*) 0x08000000);

 Jump_To_Application();

};

Linda
Associate II
Posted on August 20, 2015 at 17:26

Dear Sir,

I still can not make the LSE work, I can not detect any signal from the crystal. 

static void RTC_Config(void)

{

  EXTI_InitTypeDef  EXTI_InitStructure;

  NVIC_InitTypeDef  NVIC_InitStructure;

 

  /* Enable the PWR clock */

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

  /* Allow access to RTC */

  PWR_BackupAccessCmd(ENABLE);

//#if defined (RTC_CLOCK_SOURCE_LSI)  /* LSI used as RTC source clock*/

///* The RTC Clock may varies due to LSI frequency dispersion. */   

//  /* Enable the LSI OSC */ 

//  RCC_LSICmd(ENABLE);

 RCC_LSICmd(DISABLE);

//  /* Wait till LSI is ready */  

//  while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)

//  {

//  }

//  /* Select the RTC Clock Source */

//  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

//  

//#elif defined (RTC_CLOCK_SOURCE_LSE) /* LSE used as RTC source clock */

  /* Enable the LSE OSC */

  RCC_LSEConfig(RCC_LSE_ON);

  /* Wait till LSE is ready */  

  while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)

  {

  }

  /* Select the RTC Clock Source */

  RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);

//#else

////  #error Please select the RTC Clock source inside the main.c file

//#endif /* RTC_CLOCK_SOURCE_LSI */

  

  /* Enable the RTC Clock */

  RCC_RTCCLKCmd(ENABLE);

  /* Wait for RTC APB registers synchronisation */

  RTC_WaitForSynchro();

  /* RTC Wakeup Interrupt Generation: Clock Source: RTCCLK_Div16, Wakeup Time Base: ~4s

     Wakeup Time Base = (16 / (LSE or LSI)) * WakeUpCounter

  */

  RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);

  RTC_SetWakeUpCounter(0x1FFF);

  /* Enable the Wakeup Interrupt */

  RTC_ITConfig(RTC_IT_WUT, ENABLE);

  /* Connect EXTI_Line22 to the RTC Wakeup event */

  EXTI_ClearITPendingBit(EXTI_Line22);

  EXTI_InitStructure.EXTI_Line = EXTI_Line22;

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

  EXTI_InitStructure.EXTI_LineCmd = ENABLE;

  EXTI_Init(&EXTI_InitStructure);

  

  /* Enable the RTC Wakeup Interrupt */

  NVIC_InitStructure.NVIC_IRQChannel = RTC_WKUP_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

}