3.2 RTC Not working??? I really don't understand what I did to this thing.

usererror

Active member
I soldered a crystal into the Teensy 3.2, and the Time program no longer runs. Prior to this it could be seen running in the serial console.

I removed the crystal, and nothing changed - the Time program still did not run.

I uploaded a different program trying to see if I just had a bad upload, and now its just confusing. The blink demo won't run, the time demo won't run, but I can run an OLED using I2C just fine.

Did a system reboot, and swapped USB cables just to be sure its not a communication issue.

I am presuming I overheated or shorted a nearby surface mount part. I can't find any evidence of that though. I was as quick as I could be with the heat, and kept my distance from other components. It seems like its just the RTC function that isn't working now or something.



Just some added info: Only external components I've run this with is the Adafruit 128x64 OLED, not including the crystal attempt.

The LED does occasionally try to blink, but it is extremely dim (barely visible in a dark room), and seems to be random.



<<Trying to delay the sinking feeling of knowing I just borked $25 and the time waiting for it to arrive within an hour of putting code to it>>





[] Complete Source Code (or a link to the code)
The Time Teensy3 example used to run, now does not.
I also included the two programs that I was running prior to the issues.
The first runs, and just graphs out random data on the oled (just wanted to see how it performed vs an atmel 328).
The second is a modified version of the Time example (the example unmodified does not run either so it has nothing to do with my modifications to the code, as even the modified version ran until the crystal). This just spits out the time on the OLED.
What is really puzzling me about this is that the Blink tutorial won't run now.
For some reason uploading any software now seems to take an age as well (several minutes).


[] Screenshot or the exact text of any error messages
I'll see if I can find my macro lense for my camera to get some upclose pix - maybe someone else spots my goofup where I didn't.

[] Which PJRC product you're using
Teensy 3.2

[] Part numbers of any other chips or modules + links to their info
Crystal was labeled "32.768" on scotch tape in my bin. Maybe I used something I should not have.
I believe it was salvaged from a watch, but it might have been from something else.

[] Wiring details - how exactly have you connected the hardware (a photo's worth 1000 words)
Already pulled the part so its a bit late for a picture.

[] Software setup, Arduino vs C+makefile, running on Windows, Mac or Linux?Versions?
Linux, 1.6.6

[] Any other information needed to reproduce the problem.....
I'm not sure this is a 'reproduce the problem' kind of thing, and more just someone confirming I did in fact bork it before I toss it in the bin.






========================== THIS RUNS =============================

//add smoothing
/*****
* last tampered with - 23 DEC 2015 05:43
*
* Changed boot charge readout from "***" to "**%" -- 04 JAN 2016 09:55
* Also messed with variable smoothing but its effectively back at prior defaults/settings -- 04 JAN 2016 10:05
*
* Changed OLED_RESET to pin 2 for Teensy3.2 -- 23JAN2016
* */



/* *************************************************** */
// OLED DISPLAY:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 2
Adafruit_SSD1306 display(OLED_RESET);
/* *************************************************** */

int sensorValue = 0;
int verticalValue = 0;
int count2 = 0;

/**** This is where you set your smoothing - 3 = really nice, 1 = none, 15 = really heavy smoothing ****/
const int numReadings = 3;

int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average


//
int count = 0;


void setup()
{

display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // initialize with the I2C addr 0x3D (for the 128x64)
// init done
display.clearDisplay();
display.drawFastHLine(0, 36, 128, 1); // starting x axis, y axis, length, color
display.drawFastHLine(0, 10, 128, 1); // starting x axis, y axis, length, color
display.drawFastHLine(0, 62, 128, 1); // starting x axis, y axis, length, color
// display.setTextSize(1);
// display.setTextColor(WHITE);
//display.setCursor(110, 0);
//display.println("**%"); // battery monitor display - show blank to give at least one cycle to calulate..
display.display();
}

void loop()
{
//sensorValue = random(12, 60);

// SMOOTHING BEGIN
// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = random(12, 60);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;

// if we're at the end of the array...
if (readIndex >= numReadings)
{
// ...wrap around to the beginning:
readIndex = 0;
const int numReadings = random(1, 25); // randomize smoothing from 1-15, aka little to max smoothing
}

// calculate the average:
sensorValue = total / numReadings;
if(sensorValue >= 61)
{
sensorValue = 60;
}
// SMOOTHING END

//if (sensorValue >= 12 && sensorValue <= 60)
//{
verticalValue = sensorValue - 60;
if (count2 == 128)
{
count2 = 0;
display.clearDisplay();
display.drawFastHLine(0, 36, 128, 1); // starting x axis, y axis, length, color
display.drawFastHLine(0, 10, 128, 1); // starting x axis, y axis, length, color
display.drawFastHLine(0, 62, 128, 1); // starting x axis, y axis, length, color
// voltageMonitor(); // run voltage monitor and display value
}

//display.drawFastVLine(count2, sensorValue, verticalValue, WHITE); // instead of dot, a line
display.drawLine(count2, sensorValue, count2, 60, WHITE); // another option
count2++;
//}
display.display();

}

====================================================================


============================ THIS DOES NOT RUN ======================

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


http://www.pjrc.com/teensy/td_libs_Time.html
*/

#include <TimeLib.h>

/* *************************************************** */
// OLED DISPLAY:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define OLED_RESET 2
Adafruit_SSD1306 display(OLED_RESET);
/* *************************************************** */

// Teensy 3.0 has the LED on pin 13
const int ledPin = 13;

/* *************************************************** */
/* *************************************************** */
/* *************************************************** */



void setup() {
pinMode(ledPin, OUTPUT);
display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // initialize with the I2C addr 0x3D (for the 128x64)
// init done
display.clearDisplay();
display.display();

display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 0);

// 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");
display.println("Unable to sync with the RTC");
} else {
Serial.println("RTC has set the system time");
display.println("RTC has set the system time");
}
display.display();
digitalWrite(ledPin, HIGH); // set the LED on
delay(2000);
digitalWrite(ledPin, LOW); // set the LED off
}

/* *************************************************** */

void loop() {
if (Serial.available()) {
time_t t = processSyncMessage();
if (t != 0) {
Teensy3Clock.set(t); // set the RTC
setTime(t);
digitalWrite(ledPin, HIGH); // set the LED on
}
}
digitalClockDisplay();
delay(1000);
digitalWrite(ledPin, LOW); // set the LED off
}

/* *************************************************** */

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();

display.clearDisplay();

display.setTextSize(4);
display.setTextColor(WHITE);
display.setCursor(0, 0);

display.print(hour());
display.print(":");
display.print(minute());

display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0, 40);

display.println("");
display.print(day());
display.print(".");
display.print(monthShortStr(month()));
display.print(".");
display.print(year());


display.display();
}

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);
}

========================================================================================
 
Okay - per usual, 30 seconds after I submit the post I spent 20 minutes writing, something changes.

The Time program above is now working as it was prior to the issues arising. I just slammed the upload button and swapped ports and pushed the 'reset' button over and over until it did something resembling working. Its still taking a lot longer to upload than it did prior (it really is a push upload (or use keybind as I do)), and then watch a three minute youtube video, then it should be done uploading a fairly small sketch, but you may have to manually push the 'reset' button and/or try uploading it again.

I also still cannot for the life of me get this thing to blink. I got it to upload the blink program (I really just can't bring myself to call them sketches) just fine (or so it seems), but blinking seems to be a no-go.
 
Do you have a voltmeter? Maybe check pin 13 to see if the voltage is actually changing while the blink program is trying to run?
 
If you're using Windows - and from the sound of this strangeness I'm guessing this is Windows - do yourself a favor and cold reboot your computer before trying anything else!
 
Ran the blink demo and on pin 13 and saw .1v, so I changed the pin to 11, reuploaded it, then back to 13 and reuploaded it again and now I see 3.2v/.01v high/low, and it is properly blinking.

This is on Linux (Ubuntu base), and I have a Manjaro box (arch base) near enough that I can try later on if need. I did two full reboots just to be sure earlier as sometimes my box likes to hold onto ports and not let them go.

So far everything feels like user error of some sort or another. Perhaps some of it is a hardware issue on the side of my computer though (it is some very quirky old hardware that has fought me on everything for ongoing 7 years now).

Any ideas on why the uploads would take 2-3 minutes? Or why it'd sometimes auto reset but other times need to be done manually?
 
I have switched between two ports and two cables already. I'll try a different computer later, and see if I can source one of my more heavily shielded cables in case its a bad or crappy cable. Maybe I have an EM leak or something like that. It would not shock me if it were the mainboard's hub causing issues or something like that. If I find something that sorts it out I'll update this thread in case it can help someone in the future.

Anyway: Thanks for the help Paul, and thank you for making the product I needed, and a great price-point, to make what I have been wanting to make, but just couldn't get done with the typical arduino. I'm betting after I get used to the differences and fix any gray matter issues, the Teensy and I will get along just fine.
:)
 
Back
Top