Teensy3Clock.get() returns error

Status
Not open for further replies.

pak

Member
I am developing a bilge pump counter/elapsed time for my boat. The project is nearly complete and the code ran fine until yesterday when my master boot record became corrupt. I corrected the problem by using my original Windows 7 CD and all of my programs are back up and running… Photoshop, Solidworks, Alibre, Eclipse, MS Visual Studio Express, even Arduino 1.6.5, to name just a few. However, “Teensy3Clock.get()” returns the following error when running the TimeTeensy3 example. It just won't compile. I have not altered the code in any way from the original, as you can see from below. My sketch runs fine on my laptop running V1.0.5. I uninstalled V1.0.5 on my desktop and installed 1.6.5 the other day. I just did the same a few minutes ago with 1.6.5 just to make sure. I don't know if the problem existed before the MBR went bad or it was because I had not yet run it on the current version. What do you suppose the problem is?

Error Message
Arduino: 1.6.5 (Windows 7), TD: 1.25, Board: "Arduino/Genuino Uno"
Build options changed, rebuilding all
Using library Time in folder: C:\Program Files (x86)\Arduino\libraries\Time (1.0.x format)
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Program Files (x86)\Arduino\libraries\Time C:\Users\Drew\AppData\Local\Temp\build1672556687890403424.tmp\TimeTeensy3.cpp -o C:\Users\Drew\AppData\Local\Temp\build1672556687890403424.tmp\TimeTeensy3.cpp.o
TimeTeensy3.ino: In function 'void loop()':
TimeTeensy3.ino:27:7: error: 'Teensy3Clock' was not declared in this scope
TimeTeensy3.ino: In function 'time_t getTeensy3Time()':
TimeTeensy3.ino:51:10: error: 'Teensy3Clock' was not declared in this scope
'Teensy3Clock' was not declared in this scope

Code
/*
* TimeRTC.pde
* example code illustrating Time library with Real Time Clock.
*
*/

#include <Time.h>

void setup() {
// set the Time library to use Teensy 3.0's RTC to keep time
setSyncProvider(getTeensy3Time);

Serial.begin(115200);
while (!Serial); // Wait for Arduino Serial Monitor to open
delay(100);
if (timeStatus()!= timeSet) {
Serial.println("Unable to sync with the RTC");
} else {
Serial.println("RTC has set the system time");
}
}

void loop() {
if (Serial.available()) {
time_t t = processSyncMessage();
if (t != 0) {
Teensy3Clock.set(t); // set the RTC
setTime(t);
}
}
digitalClockDisplay();
delay(1000);
}
//
void digitalClockDisplay() {
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}

time_t getTeensy3Time()
{
return Teensy3Clock.get();
}

/* code to process time sync messages from the serial port */
#define TIME_HEADER "T" // Header tag for serial time sync message

unsigned long processSyncMessage() {
unsigned long pctime = 0L;
const unsigned long DEFAULT_TIME = 1357041600; // Jan 1 2013

if(Serial.find(TIME_HEADER)) {
pctime = Serial.parseInt();
return pctime;
if( pctime < DEFAULT_TIME) { // check the value is a valid time (greater than Jan 1 2013)
pctime = 0L; // return 0 to indicate that the time is not valid
}
}
return pctime;
}

void printDigits(int digits){
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}

System Information
OS Name Microsoft Windows 7 Professional
Version 6.1.7601 Service Pack 1 Build 7601
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Name N/A
System Manufacturer Gigabyte Technology Co., Ltd.
System Model To be filled by O.E.M.
System Type x64-based PC
Processor Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz, 3901 Mhz, 4 Core(s), 8 Logical Processor(s)
BIOS Version/Date American Megatrends Inc. F7, 5/11/2012
SMBIOS Version 2.7
Windows Directory C:\Windows
System Directory C:\Windows\system32
Boot Device \Device\HarddiskVolume4
Locale United States
Hardware Abstraction Layer Version = "6.1.7601.17514"
User Name N/A
Time Zone Eastern Daylight Time
Installed Physical Memory (RAM) 16.0 GB
Total Physical Memory 16.0 GB
Available Physical Memory 13.8 GB
Total Virtual Memory 31.9 GB
Available Virtual Memory 28.2 GB
Page File Space 16.0 GB
Page File C:\pagefile.sys
 
The error message indicates you are compiling it for an Arduino/Uno. You need to change it to Teensy 3.1/3.2. Note, the Teensy LC does not have the real time clock.
 
This Looks Like the easy fix.
TeensyArduinoOptions.JPG
 
Thank you all. Problem solved. I presume the compiler changed when I did an Acronis restore, which is when the MBR got overwritten. However, when I reinstalled 1.6.5 it also wrote over the teensyduino files and gave me a file missing error. I reinstalled teensyduino and everything is fine now. As you can see from my many posts :), I'm not real experienced. Thank you all very much. You saved me many hours. Kind regards. Drew
 
Status
Not open for further replies.
Back
Top