cancel
Showing results for 
Search instead for 
Did you mean: 

RTC daylight saving time STM32f3 discovery

abelletoile9
Associate II
Posted on February 25, 2013 at 17:18

I'm using the standard peripheral library to manage the RTC on my STM32f3 discovery board.

As I understand it, when things are running, you can go into the daylight saving time mode by this command :

RTC_DayLightSavingConfig(RTC_DayLightSaving_ADD1H, RTC_StoreOperation_Set);

Which add 1h to the RTC hour and set the RTC_BCK (or RTC_BKP) bit to 1.

Reversely, when winter is coming, I use this command :

RTC_DayLightSavingConfig(RTC_DayLightSaving_SUB1H, RTC_StoreOperation_Reset);

And between those days, I can use the RTC_BCK bit to be check if I'm in daylight saving time or not via the GetStoreOperation() function.

All of this is very fine with me except that, at the first start-up, I can't set the RTC_BCK bit during the RTC initialization. The only way I figured out to do so is either to go and write directly the RTC_BCK bit or use a trick like this :

RTC_DayLightSavingConfig(RTC_DayLightSaving_ADD1H, RTC_StoreOperation_Set);

RTC_DayLightSavingConfig(RTC_DayLightSaving_SUB1H, RTC_StoreOperation_Set);

So that the time remain the same but I know the status of the RTC_BCK bit.

Eventually, I'm not very happy with this trick : I don't find it very elegant and I'm afraid I missed something. So I turned to you to explain me if I missed something!

Is there any function to set the RTC_BCK bit?

Is my usage of this bit correct?

Am I supposed to write directly the bit whereas no mention of this operation could be found in the UM1581?

Thanks in advance for your answer and/or explaination!

Arno

4 REPLIES 4
Posted on February 26, 2013 at 08:41

> Is my usage of this bit correct?

Yes.

> Am I supposed to write directly the bit whereas no mention of this operation could be found in the UM1581?

Why not.

As you might have already discovered, the ''library'' is nothing but a very thin ''layer'' upon the peripheral registers, so at the and of the day, there is little to no benefit using it instead of going directly to the registers themselves; unless you believe that it would help you moving to a different mcu.

YMMV.

JW

Posted on February 26, 2013 at 09:06

Apropos, I can't find UM1581 you mention.

JW
abelletoile9
Associate II
Posted on February 27, 2013 at 09:57

Hi Jan,

Thanks for this clarification!

I'm glad to hear that I wasn't completely wrong on the basic idea :)

A propos de la UM1581 reference, the complete title is ''Description of STM32F30xx/31xx Standard Peripheral Library''. I don't really know where I got this but it seems foundable on giigle. I found it rather clear and it was a helpful starting reference (together with the user manual) for me.

Thanks again for your post.

Best regards,

Arno

abelletoile9
Associate II
Posted on February 27, 2013 at 10:00

seems findable on google...

sorry for that. :p