Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 4:a9cebfe4715f
- Parent:
- 3:7b3edf54c706
- Child:
- 5:bc464a588c2e
diff -r 7b3edf54c706 -r a9cebfe4715f main.cpp
--- a/main.cpp Wed Feb 18 09:15:37 2015 +0000
+++ b/main.cpp Thu Feb 19 02:59:11 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 18th, 2015
+ * Revised: Feburary 19th, 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
@@ -54,6 +54,8 @@
char buf[42]; // data buffer for text
time_t seconds;
uint8_t counter = SHOW_KEY_PROMPT;
+ uint8_t wait_counter = 0;
+ uint8_t xtal = 0;
#if defined(USE_LCD)
// lcd
@@ -67,10 +69,12 @@
#endif
pc.printf("\r\n\r\nTest Nucleo RTC Function\r\n");
myled = !myled;
- if (SetRTC() == OK) {
+ if (SetRTC() == 1) {
pc.printf("External");
+ xtal = 1;
} else {
pc.printf("Internal");
+ xtal = 0;
}
pc.printf(" Xtal for RTC\r\n");
show_RTC_reg(); // only for debug purpose
@@ -82,7 +86,11 @@
while(1) {
seconds = time(NULL);
strftime(buf, 40, " %B %d,'%y, %H:%M:%S\r\n", localtime(&seconds));
- pc.printf("[Time] %s", buf);
+ if (xtal){
+ pc.printf("[Time] %s", buf);
+ } else {
+ pc.printf("[Time by Internal Clock] %s", buf);
+ }
#if defined(USE_LCD)
lcd.locate(0, 0); // 1st line top
strftime(buf, 40, "%b%d'%y", localtime(&seconds));
@@ -96,6 +104,7 @@
// 012345678901234567890123456789012345678901234567890123456789012
pc.printf("Is time correct? If no, hit any key.\r");
}
+ wait_counter = 0;
while (seconds == time(NULL)){
if (pc.readable() == 1){
buf[0] = pc.getc(); // dummy read
@@ -116,6 +125,15 @@
myled = 0;
goto_standby();
}
+ wait(0.05);
+ if (++wait_counter > (2000 / 50)){
+ if (xtal){
+ pc.printf("Time was not updated! External Xtal does NOT oscillate.\r\n");
+ } else {
+ pc.printf("Time was not updated! LSI does NOT work.\r\n");
+ }
+ break;
+ }
}
if (counter){
// 12345678901234567890123456789012345678901234567890