RTC module is working fine when power is on.
But power changes to off, RTC value remained before power off.
I don't use external battery. Just use RTC battery and the battery is not discharged. (Coin cell battery)
I want to know how to use RTC battery when power is off. (I'm using STM32F407ZG)
Thanks.
How to continue RTC when power is off
How to continue RTC when power is off
- Attachments
-
- config.png (3.27 KiB) Viewed 1417 times
Re: How to continue RTC when power is off
Hi,
Did you connect the battery to the adequate pin - VBAT?
Regards,
Filip.
Did you connect the battery to the adequate pin - VBAT?
Regards,
Filip.
Re: How to continue RTC when power is off
Hi,
I think my connection is right...
But, I want to confirm it.
Attach connection screenshot.
<Additional>
Where is VBAT pin??
Thanks.
I think my connection is right...
But, I want to confirm it.
Attach connection screenshot.
<Additional>
Where is VBAT pin??
Thanks.
- Attachments
-
- connection.jpg (277.7 KiB) Viewed 1351 times
Re: How to continue RTC when power is off
Hi,
OK, you have a mikromedia board so everything is connected as it should.
Which RTC example did you try ?
Regards,
Filip.
OK, you have a mikromedia board so everything is connected as it should.
Which RTC example did you try ?
Regards,
Filip.
Re: How to continue RTC when power is off
I'm using "RTC for STM32F2xx/3xx/4xx" RTC library.
< In "driver.c" >
RTC_InitStruct rtcInit;
//RTC_DateTime timeRTC; // for once
...
void Init_MCU() {
rtcInit.RTC_HF = RTC_HourFormat_24;
rtcInit.RTC_AsynchPrediv = RTC_ASYNC_PREDIV;
rtcInit.RTC_SynchPrediv = RTC_SYNC_PREDIV;
RTC_Init(&rtcInit);
// set RTC once
// timeRTC.Year = 21;
// timeRTC.Month = 01;
// timeRTC.Date = 04;
// timeRTC.Hours = 13;
// timeRTC.Minutes = 30;
// timeRTC.Seconds = 30;
// timeRTC.AMPMSel = RTC_AMPMSel_AM;
// RTC_SetDateTime(&timeRTC);
...
}
< In events_code.c >
void event_handler() {
RTC_DateTime rtcDateTime;
RTC_GetDateTime(&rtcDateTime);
...
}
Thanks.
< In "driver.c" >
RTC_InitStruct rtcInit;
//RTC_DateTime timeRTC; // for once
...
void Init_MCU() {
rtcInit.RTC_HF = RTC_HourFormat_24;
rtcInit.RTC_AsynchPrediv = RTC_ASYNC_PREDIV;
rtcInit.RTC_SynchPrediv = RTC_SYNC_PREDIV;
RTC_Init(&rtcInit);
// set RTC once
// timeRTC.Year = 21;
// timeRTC.Month = 01;
// timeRTC.Date = 04;
// timeRTC.Hours = 13;
// timeRTC.Minutes = 30;
// timeRTC.Seconds = 30;
// timeRTC.AMPMSel = RTC_AMPMSel_AM;
// RTC_SetDateTime(&timeRTC);
...
}
< In events_code.c >
void event_handler() {
RTC_DateTime rtcDateTime;
RTC_GetDateTime(&rtcDateTime);
...
}
Thanks.
- Attachments
-
- RTC_library.png (17.71 KiB) Viewed 1322 times
Re: How to continue RTC when power is off
Hi,
Please have a look at the following links, you will see there how to properly set the RTC on STM32 :
https://libstock.mikroe.com/projects/vi ... ternal-rtc
viewtopic.php?f=178&t=50510
viewtopic.php?f=178&t=49563
Regards,
Filip.
Please have a look at the following links, you will see there how to properly set the RTC on STM32 :
https://libstock.mikroe.com/projects/vi ... ternal-rtc
viewtopic.php?f=178&t=50510
viewtopic.php?f=178&t=49563
Regards,
Filip.
Re: How to continue RTC when power is off (solved)
Thanks for filip, I solved problem.
1) Using “REGISTER-NAMEbits.NAME-OF-BIT” instead of “REGISTER-NAME.NAME-OF-BIT”
2) Using LSE clock for RTC clock source (in my case, RCC_BDCR register is set after RCC_BDCR resets.)
I found external reset (push reset button in board) repeats, RTC value differences from real time.
Thanks.
1) Using “REGISTER-NAMEbits.NAME-OF-BIT” instead of “REGISTER-NAME.NAME-OF-BIT”
2) Using LSE clock for RTC clock source (in my case, RCC_BDCR register is set after RCC_BDCR resets.)
I found external reset (push reset button in board) repeats, RTC value differences from real time.
Thanks.