cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX RTC number format

StefanRickli
Associate II

All input fields in the RTC section for dates and times suggest that I'm entering a decimal value. But the generated code interprets my input as Hex.

I.e. if I enter 10 in the field for the RTC alarm seconds, the code sets "sAlarm.AlarmTime.Seconds = 0x10;"

This confusion arises because the value check of these fields can only be "Decimal" or "No Check". When I check "Hexadecimal", the selection stays at the last selected choice.

STM32CubeIDE 1.8.0

Selected MCU in CubeMX: STM32L422RBIx

2 REPLIES 2
KnarfB
Principal III

RTCs traditionally often use BCD (binary coded decimal) format using 4-bit per decimal digit. The most close format C offers natively is hex, also using 4-bit per (hex-)digit. In BCD logic 0x10 is October, 0x31 the last day in March etc... Addition is decimal, e.g. 0x09 + 0x01 = 0x10.

hth

KnarfB

Cube is open source, so you can easily look up how the RTC functions treat those values.

You may also want to read the documentation, in this case the RTC-related chapters in UM1884.

JW