Teensy3.1 USB Serial and RTC test. Use this program to check the operation of the RTC after the 32KHz crystal has been fitted. If a back up cell has also been fitted the RTC will remain running after the main power has been removed. Reconnect the USB to the PC and the RTC time will be displayed when using a PC terminal program.

Dependencies:   USBDevice mbed-src

Fork of USBSerial-RTC-HelloWorld by Community Contributors

Revision:
12:f4e5544977c2
Parent:
11:7bf81089fce6
--- a/main.cpp	Mon Jun 15 23:10:36 2015 +0000
+++ b/main.cpp	Wed Sep 30 22:24:41 2015 +0000
@@ -2,9 +2,13 @@
 
 // Requires 32KHz crystal fitted.
 // Unplug then plug back in the Teensy after programing to reactivate the Teensy USB serial port.
+// if your terminal program can't see the Teensy
 
 #include "mbed.h"
 #include "USBSerial.h"
+
+// include to check/display clock rates
+#include "clk_freqs.h"
  
 //Virtual serial port over USB
 USBSerial serial;
@@ -12,12 +16,12 @@
 DigitalOut led(LED1);
 
 struct tm t;
-char timebuff[60];
+char timebuff[80];
 
-int minute      =35;    // 0-59
-int hour        =18;    // 0-23
-int dayofmonth  =14;    // 1-31
-int month       =6;     // 1-12
+int minute      =20;    // 0-59
+int hour        =23;    // 0-23
+int dayofmonth  =30;    // 1-31
+int month       =9;     // 1-12
 int year        =15;    // last 2 digits
  
 void setRTC()
@@ -33,13 +37,22 @@
  
 int main(void) {
  
-    setRTC(); // If back up cell fitted, comment this out after the RTC has been set then re-program.  
+    led=1;
+    
+    //setRTC(); // If back up cell fitted, comment this out after the RTC has been set then re-program.  
     
     while(1)
     {   
         time_t seconds = time(NULL);
-        strftime(timebuff,60,"Teensy RTC\r\nTime:  %H:%M:%S\r\nDate:  %A %d %B %Y\r\n\n", localtime(&seconds));       
-        serial.printf(timebuff);
+        strftime(timebuff,80,"\n\n Teensy RTC\r\nTime:  %H:%M:%S\r\nDate:  %A %d %B %Y\n\n", localtime(&seconds));       
+        serial.printf(timebuff);       
+        
+        serial.printf("\n core %d",SystemCoreClock);
+        
+        serial.printf("\n Bus  %d",bus_frequency());
+        
+        serial.printf("\n Osc  %d",extosc_frequency());
+        
         led=0;        
         wait(1);
         led=1;