cancel
Showing results for 
Search instead for 
Did you mean: 

date does not update when 24Hours is exceeded on STM32F2

patrick-giles
Associate
Posted on November 25, 2013 at 22:38

Hello I am a rookie C programmer who has a problem with a STM32F2 microcontroller I have configured the RTC API according to STM, but when 24 hours is exceeded the date does not update, it only updates when you do a power cycle

can anyone help

#c #rtc
2 REPLIES 2
emalund
Associate III
Posted on November 26, 2013 at 16:55

 I am a rookie C programmer

 

Embedded is NOT a good place to learn C, get reasonably fluent on the PC, THEN tackle embedded

can anyone help

 

not unless you show your code

Erik
jpeacock2399
Associate II
Posted on November 27, 2013 at 15:58

When you access the RTC registers you are reading from shadow copies.  To guard against simultaneous updates (i.e. time rolls over to new day while reading the date register first) the two shadow registers are locked against updates.  Make sure you read both registers, not just RTC_TR, to free the update lock.  From the 'F2 manual:

To ensure consistency between the 2 values, reading RTC_TR locks the values in the higher-order calendar shadow registers until RTC_DR is read.

As for being new to C, well, everyone has to start somewhere.  In the bad old days when big iron dinosaurs roamed the Earth (who remembers Univac or XDS now?) embedded programmers did not have the luxury of starting with C, or even assembly language.  The only tool was the front panel deposit switch on that old DG Nova or PDP-8 and a piece of paper to write down the binary.  So ignore the slanted remarks from the Peanut Gallery (and only those who remember big iron machines know what the Peanut Gallery was) and forge ahead with your embedded project.  But don't entirely ignore Erik's advice, he also has more than a few years experience to draw on.