Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


STM32F103C8T6 RTC year keeps defaulting to 2000, time however OK

Strange problem.
The RTC seems to be working.
Once set up, the RTC time is working but when CPU does power cycle, the time is OK, but the year keeps defaulting to 2000.

It is probably I’m doing something wrong.

I set the clock using MX_RTC_Init() which has the time and date hard coded into it from the defaults it receives from STM23CubeMX setup.

The next time I run, I don’t run MX_RTC_Init()
(If I did, the hard coded time will be written back into the RTC).

and then run HAL_RTC_GetTime(&hrtc, &RTC_Time, RTC_FORMAT_BIN);
which fetches the battery backed time - the time is correct.

At this point, I am assuming all the data structures have initialised
properly even though I have not run MX_RTC_Init()

and then I do HAL_RTC_GetDate(&hrtc, &RTC_Date, RTC_FORMAT_BIN);
this however has defaulted the year to 2000.

This default date is being set I think in
HAL_StatusTypeDef HAL_RTC_Init(RTC_HandleTypeDef *hrtc) which is in file stm32f1xx_hal_rtc.c
(I don’t think we are supposed to modify this file.)

The time function is OK, so Is there some step I missed to get the corret date out of the RTC?

TIA

I have the same problem. Could you solve it?
I miss the date, but the time is still working correctly.


I don’t know if this is still true but, a while back the initialization code for the RTC would set the date. There was no “unitialized” flags being used to bypass the setting of the date. It seemed like an odd choice and the problem was sent to ST, but I never followed the issue.

Put some break points in the startup code and see if the RTC has the proper date, then step through. It sounds like that init code is still around.

Andrei


Thanks for reply.

After of read tons of documentation and forums, I decided don’t spend more time and use an external clock DS1307.

Apparently the STM32F103 does not have calendar functions, and only has one counter for seconds. Because date reset when reset device. We need implement calendar by software, but the accuracy of RTC was also not convincing me, calculating if it was delayed 5 minutes per day.

When I get my discovery with stm32f4 and have time, I will test if the calendar works. Meanwhile I need to continue with the project. biggrin


Thank skalibur - yours is best answer - I go use DS1307 to resurect the original project.

 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs