RTC sub-seconds prescaler register not writable

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
Dugite
Posts: 21
Joined: Thu Jan 18, 2018 1:29 pm

RTC sub-seconds prescaler register not writable

Post by Dugite » Fri Jul 31, 2020 1:56 pm

Hello,

I have a Pyboard V1.1 project using Micropython 1.12 where I would like to change the RTC sub-seconds from 4ms to 1ms.

From the STM32 manual (RM0090) there is the 32,768 Hz RTC coming into the "RTC_PRER" register and by default this is set to 0x7f (127) giving an output frequency of 256Hz for the sub-seconds.

When I change RTC_ASYNCH_PREDIV to 0x1f to give 1024Hz it does not do anything. I have also tried writing directly to the register "hrtc->Instance->PRER" in "rtc.c" but it makes no difference to the default register settings.

I see there is a method called to unlock the RTC registers so it appears like this is perhaps not working and write protection is enabled?

Any comments or thoughts on this would be much appreciated.

UPDATE: I also tried writing directly to the STM32F4xx HAL RTC file as shown in the attachment, recompiled the code and loaded into the board but the sub-seconds still counts from 255 to 0.
Attachments
micropython-rtc-STM32F4-HAL.JPG
micropython-rtc-STM32F4-HAL.JPG (61.01 KiB) Viewed 1730 times
micropython-rtc-boardconfig.JPG
micropython-rtc-boardconfig.JPG (60.99 KiB) Viewed 1733 times
micropython-rtc-PREDIV.JPG
micropython-rtc-PREDIV.JPG (54.08 KiB) Viewed 1734 times
micropython-rtc-PRER.JPG
micropython-rtc-PRER.JPG (116.29 KiB) Viewed 1735 times

chuckbook
Posts: 135
Joined: Fri Oct 30, 2015 11:55 pm

Re: RTC sub-seconds prescaler register not writable

Post by chuckbook » Sat Aug 01, 2020 5:48 pm

Keep in mind that the RTC has to be fully powered down to change it's configuration.

User avatar
Dugite
Posts: 21
Joined: Thu Jan 18, 2018 1:29 pm

Re: RTC sub-seconds prescaler register not writable

Post by Dugite » Sun Aug 02, 2020 12:21 am

@chuckbook

Thank you for the reply.

I did try changing the default PRER value in the STM32 HAL file which should set it's default value on power up so I would have thought this should have changed the prescalar value? I noticed in the STM32 manual that the reset value is the same as the default value written so it appears it is never changing (0x007F00FF). Note that I changed the default value below to 0x001F00FF from 0x007F00FF.

It also seems that "HAL_RTC_DeInit(RTC_HandleTypeDef *hrtc)" is not called from MicroPython.
Attachments
stm32-PRER-register-map.JPG
stm32-PRER-register-map.JPG (106.7 KiB) Viewed 1696 times
micropython-rtc-STM32F4-HAL.JPG
micropython-rtc-STM32F4-HAL.JPG (61.01 KiB) Viewed 1701 times

Post Reply