STM32F0 rtc alarm 1 day
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-10-19 1:39 AM
Hi, How can I setting rtc to put alarm every 1 day , for all day? Is possible
(I need to wake up stm32f0 every 16:00 pm all day , execute routine and do sleep and waitthe next day
)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-10-19 7:48 AM
Something like
/* Disable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, DISABLE); /* Set the alarm to 4PM (16:00) daily*/ RTC_AlarmStructure.RTC_AlarmTime.RTC_H12 = RTC_H12_PM; RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = 0x04; RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = 0x00; RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = 0x00; RTC_AlarmStructure.RTC_AlarmDateWeekDay = 0x31; // Nonspecific RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date; RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_Hours | RTC_AlarmMask_Minutes | RTC_AlarmMask_Seconds; // HH:MM:SS match RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure); /* Enable RTC Alarm A Interrupt: this Interrupt will wake-up the system from STANDBY mode (RTC Alarm IT not enabled in NVIC) */ RTC_ITConfig(RTC_IT_ALRA, ENABLE); /* Enable the Alarm A */ RTC_AlarmCmd(RTC_Alarm_A, ENABLE); /* Clear RTC Alarm Flag */ RTC_ClearFlag(RTC_FLAG_ALRAF);Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-10-22 2:08 AM
Just be aware of oscillator accuracy - if it is possible check frequency with oscilloscope to set Prescaler to more accurate setting because 1% in 24 hours (86400 seconds) might come up to 846 seconds (which is almost 15 minutes) delay - really really fine tuning of capacitors should be considered!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-10-22 8:18 AM
Just be aware of oscillator accuracy - if it is possible check frequency with oscilloscope to set Prescaler to more accurate setting because 1% in 24 hours (86400 seconds) might come up to 846 seconds (which is almost 15 minutes) delay - really really fine tuning of capacitors should be considered!
Most 32.768 KHz crystals are in the PPM range, 20 PPM being 0.002%, less than 2 seconds. If you're losing/gaining 15 minutes a day you've got bigger part selection problems than a couple of capacitors. STM32 parts have classically only used LSE to run the RTC when the part is shutdown as it uses far less power than the LSI RC oscillator.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-10-23 12:55 AM
I have measured my crystal (i dont have Discovery board btw) with scope and it showed 32.7659 Hz and even if I take the last number as ''mistake'' of scope, then its 2 Hz off what it is suppose to be. Without correction to Prescaler that meant quite nice mistake over longer periods of time (and I have interrupt routine cleared and am printing time in main loop). Without going to assembler I do not think I could optimise my program more, so I cant really say where else would I loose time (i make interrupts every second).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-10-23 3:43 AM
What's the problem then.
If I'm not mistaken 2Hz is about 5s/day -- not bad, you can finetune it with prescaler under 0.5Hz or 1.3sec/day.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-10-23 6:22 AM
Then only my maths is wrong...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-10-23 6:40 AM
You want to measure the LSE indirectly, sticking a scope probe on it changes the loading. Other STM32 family parts connect an internal copy to one of the timer inputs.
On the F0 RTCCLK can be routed to TIM14 CH1, as can the MCO pin, which can be configured to output LSI, LSE, etc.Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-02-22 11:29 AM
Hi,
I am trying to configure rtc alarm which will generate alarm on 23:00:00(hh:mm:ss) everyday. here is my code, *------------------------------------------------------------------------------*/ void RTC_IRQHandler(void) { if(RTC->ISR & RTC_ISR_ALRAF){ GPIOA-> ODR |= (1 << 1); } RTC->ISR &= ~(1<<8); } void RTCAlrmConfig(){ RTC->WPR = 0xCA; RTC->WPR = 0x53; RTC->CR &=~ RTC_CR_ALRAE; //Disable alarm interrupt while ((RTC->ISR & RTC_ISR_ALRAWF) != RTC_ISR_ALRAWF) {} RTC->ALRMAR =0x00230000; //Set alarm hour=23 and make sec min and day dont care RTC->ALRMAR |=RTC_ALRMAR_MSK1 | RTC_ALRMAR_MSK2 | RTC_ALRMAR_MSK3 | RTC_ALRMAR_MSK4; RTC->ALRMASSR=RTC_ALRMASSR_MASKSS_0 |RTC_ALRMASSR_MASKSS_1 | RTC_ALRMASSR_MASKSS_2 | RTC_ALRMASSR_MASKSS_3; RTC->CR = RTC_CR_ALRAE |RTC_CR_ALRAIE; NVIC_EnableIRQ(RTC_IRQn); NVIC_SetPriority(RTC_IRQn,3); RTC->WPR = 0xFE; RTC->WPR = 0x64; } but with this configuration I am not able to generate rtc alarm, please suggest what is wrong in this code.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-09 8:20 AM
Hi Mulani
I am having the same issue, did you get your code working? If so can you please pass it on?
Many Thanks
Scott
