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.
RTC sub-seconds prescaler register not writable
RTC sub-seconds prescaler register not writable
- Attachments
-
- micropython-rtc-STM32F4-HAL.JPG (61.01 KiB) Viewed 1730 times
-
- micropython-rtc-boardconfig.JPG (60.99 KiB) Viewed 1733 times
-
- micropython-rtc-PREDIV.JPG (54.08 KiB) Viewed 1734 times
-
- micropython-rtc-PRER.JPG (116.29 KiB) Viewed 1735 times
Re: RTC sub-seconds prescaler register not writable
Keep in mind that the RTC has to be fully powered down to change it's configuration.
Re: RTC sub-seconds prescaler register not writable
@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.
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 (106.7 KiB) Viewed 1696 times
-
- micropython-rtc-STM32F4-HAL.JPG (61.01 KiB) Viewed 1701 times