In the past, you need modify rtc_api.c in mbed-dev source code. From this revision, you can just use RTC function all of conditions (Normal, Reset, Stand-by, Power OFF).
Note
From now on, you do NOT need any modification for mbed-dev library because STM team updates rtc_api.c source code and support RTC function under reset & standby condition includes power off condition (You need additional VBAT back-up hardware).
Please refer following NOTE information.
/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/
Diff: main.cpp
- Revision:
- 5:bc464a588c2e
- Parent:
- 4:a9cebfe4715f
- Child:
- 6:5ada291037aa
--- a/main.cpp Thu Feb 19 02:59:11 2015 +0000 +++ b/main.cpp Sat May 23 22:26:37 2015 +0000 @@ -6,7 +6,7 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: January 17th, 2015 - * Revised: Feburary 19th, 2015 + * Revised: May 24th, 2015 * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE @@ -26,9 +26,10 @@ #define USE_LCD -#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_L152RE) +#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) \ + || defined(TARGET_NUCLEO_L152RE) || defined(TARGET_NUCLEO_F334R8) #else -#error "Target is only Nucleo F401RE, F411RE and L152RE" +#error "Target is only Nucleo F401RE, F411RE, F334R8 and L152RE" #endif // Object ---------------------------------------------------------------------------------------- @@ -69,7 +70,7 @@ #endif pc.printf("\r\n\r\nTest Nucleo RTC Function\r\n"); myled = !myled; - if (SetRTC() == 1) { + if (SetRTC(0) == 1) { pc.printf("External"); xtal = 1; } else {