This is a RTC additional function. This is only for Nucleo F401RE & F411RE mbed(Added L152RE, F334R8, L476RG & F746xx). If you connected battery backup circuit for internal RTC, you can make a power-off and reset condition. RTC still has proper time and date.
Dependents: Nucleo_rtos_sample PB_Emma_Ethernet
Please refer following NOTE information.
/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/
Diff: SetRTC.cpp
- Revision:
- 10:16ee1c956319
- Parent:
- 7:fa32602e23ec
- Parent:
- 9:1af4e107ca7b
- Child:
- 13:44e5327acb05
diff -r 88d30761683b -r 16ee1c956319 SetRTC.cpp --- a/SetRTC.cpp Sat May 16 01:55:33 2015 +0000 +++ b/SetRTC.cpp Sat May 23 22:18:58 2015 +0000 @@ -7,7 +7,7 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: October 24th, 2014 - * Revised: May 16th, 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 @@ -16,7 +16,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#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) //#define DEBUG // use Communication with PC(UART) @@ -109,7 +110,7 @@ timeout = HAL_GetTick() + TIMEOUT; PRINTF("Time-Out %d\r\n", timeout); // Wait till LSE is ready -#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) +#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE)|| defined(TARGET_NUCLEO_F334R8) while((RCC->BDCR & 0x02) != 2){ #else while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) { @@ -159,7 +160,9 @@ } } // Connect LSI to RTC +#if !defined(TARGET_NUCLEO_F334R8) __HAL_RCC_RTC_CLKPRESCALER(RCC_RTCCLKSOURCE_LSI); +#endif __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSI); return 1; } @@ -176,7 +179,7 @@ HAL_PWR_EnableBkUpAccess(); // Check backup condition if ( check_RTC_backup_reg() ) { -#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) +#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F334R8) if ((RCC->BDCR & 0x8307) == 0x8103){ #else if ((RCC->CSR & 0x430703) == 0x410300) { @@ -204,7 +207,9 @@ // Enable LSE Oscillator if (set_RTC_LSE() == 1) { // Connect LSE to RTC +#if !defined(TARGET_NUCLEO_F334R8) __HAL_RCC_RTC_CLKPRESCALER(RCC_RTCCLKSOURCE_LSE); +#endif __HAL_RCC_RTC_CONFIG(RCC_RTCCLKSOURCE_LSE); PRINTF("Set LSE/External\r\n"); return 1; @@ -252,9 +257,11 @@ pcr.printf( " ISR =0x...%05x, PRER =0x..%06x, WUTR =0x....%04x\r\n", RTC->ISR, RTC->PRER, RTC->WUTR ); +#if !defined(TARGET_NUCLEO_F334R8) pcr.printf( " CALIBR=0x....%04x, ALRMAR=0x%08x, ALRMBR=0x%08x\r\n", RTC->CALIBR, RTC->ALRMAR, RTC->ALRMBR ); +#endif pcr.printf( " WPR =0x......%02x, SSR =0x....%04x, SHIFTR=0x....%04x\r\n", RTC->WPR, RTC->SSR, RTC->SHIFTR @@ -264,7 +271,7 @@ RTC->TSTR, RTC->TSDR, RTC->TSSSR ); pcr.printf( "Show RCC registers (only RTC Related reg.)\r\n" ); -#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) +#if defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F334R8) pcr.printf( " RCC_BDCR=0x...%05x\r\n", RCC->BDCR); #else pcr.printf( " RCC_CSR =0x%08x\r\n", RCC->CSR); @@ -540,6 +547,6 @@ } #endif // defined(TARGET_NUCLEO_L152RE) -#else // defined(TARGET_NUCLEO_F401RE,TARGET_NUCLEO_F411RE,TARGET_NUCLEO_L152RE) +#else // defined(TARGET_NUCLEO_F401RE,_F411RE,_L152RE,_F334R8) #error "No suport this mbed, only for Nucleo mbed" -#endif // defined(TARGET_NUCLEO_F401RE,TARGET_NUCLEO_F411RE,TARGET_NUCLEO_L152RE) +#endif // defined(TARGET_NUCLEO_F401RE,_F411RE,_L152RE,_F334R8)