cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5G9J RTC 24 hours format doesn't work.

wegi01
Associate III

I work on the STM32U5G9J-DK2 and what I noticed, the RTC doesn't accepted properly hour value which is greater than 12. Than calendar doesn't work, don't actuallize and the hours going UP for example from 23 to 24 and from 24 to 25 and so on... It's really strange bcos on the STM32F407 it work flawlesly without any problem. The solution is using 12 hour format write and sign AM/PM by RTC_TimeTypeDef.TimeFormat value 0 = AM, 1 = PM. Then calendar is properly running and if anyone like me want use 24 hour time format it need realised by software.

Or if anyone know for this MCU other method to use 24H format by hardware you could be posting below.

2 REPLIES 2
waclawek.jan
Super User

Read out and check/post content of RTC registers.

Quite likely, you have inadvertently set the 12-hour mode, i.e. RTC_CR.FMT = 1. This often happens by not initializing properly the struct used to set time in Cube/HAL.

JW


@waclawek.jan wrote:

This often happens by not initializing properly the struct used to set time in Cube/HAL.


Indeed.

@wegi01 See, for example, this - which @waclawek.jan posted only the other week.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.