2014-09-12 05:22 PM
Dear all,
i connected a 32.768Khz quartz to the external clock source (PC14, PC15), i would like to have an interrupt generated each second, for the system clock. Also, i connected a battery between VBAT and gnd, to maintain time over power off. So for this purpose, i tried several samples found here and there, no one seems to work. I suspect some hardware trouble on my board, anyway, i am not sure of the samples i am looking at, could anyone suggest me a sure tutorial / appnote / link for this purpose so i am sure about the software steps ? Many thanks Angelo2014-09-13 09:13 AM
It should certainly be possible to get the RTC generating a 1 Hz interrupt, if you suspect a problem with the LSE, you should be able to check the LSE Ready signal, and time the period using TIM9, as I recall. Or expose it via one of the MCO pins.
I'll see if I can dig up or cultivate some examples on a different machine later. There should be some in either the F4 DISCO library, or F4 DSP library2014-09-14 03:04 PM
RTC_WKUP_IRQHandler
that is never triggered, i set up interrupt as:void rtc_init(void)
{ RTC_InitTypeDef RTC_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); PWR_BackupAccessCmd(ENABLE); RCC_LSEConfig(RCC_LSE_ON); while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET); RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); RCC_RTCCLKCmd(ENABLE); RTC_WaitForSynchro(); if (RTC_ReadBackupRegister(RTC_BKP_DR0) != BKP_VALUE) { /* RTC empty, first setup */ rtc_setup_time(14, 9, 14, 12, 0, 0); } /* Calendar Configuration */ /* ck_spre(1Hz) = RTCCLK(LSE) /(uwAsynchPrediv + 1)*(uwSynchPrediv + 1) */ RTC_InitStructure.RTC_AsynchPrediv = 127; RTC_InitStructure.RTC_SynchPrediv = 249; RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; RTC_Init(&RTC_InitStructure); /* EXTI configuration */ EXTI_ClearITPendingBit(EXTI_Line20); EXTI_InitStructure.EXTI_Line = EXTI_Line20; 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); RTC_WakeUpCmd(DISABLE); RTC_WakeUpClockConfig(RTC_WakeUpClock_CK_SPRE_16bits); RTC_SetWakeUpCounter(0x0); RTC_ClearITPendingBit(RTC_IT_WUT); RTC_ITConfig(RTC_IT_WUT, ENABLE); RTC_WakeUpCmd(ENABLE); RTC_WakeUpCmd(ENABLE); RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_BKPSRAM, ENABLE); } void RTC_WKUP_IRQHandler(void) { if(RTC_GetITStatus(RTC_IT_WUT) != RESET) { RTC_ClearITPendingBit(RTC_IT_WUT); EXTI_ClearITPendingBit(EXTI_Line20); } } Over the wake up not happening i have still an additional doubt: i am actually using SysTick_Handler for the system timing, but i am wondering if to use directly the more precise 32768Khz based RTL clock is a good idea. This is my assumption, but could be that have non sense.2014-09-15 08:02 AM
EXTI_Line20 ?? Wouldn't that need to be EXTI_Line22 ?
RM0090 ''EXTI line 22 is connected to the RTC Wakeup event'' STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Examples\RTC\RTC_LSI\main.c