What is with 32768 Hz crystal for the teensy 2.0 ++?

Status
Not open for further replies.

Demonclaw

Active member
What is the 32768 Hz crystal used for when it is attached to the Teensy 2.0 ++? What type of projects need this extra crystal for?
 
On the schematic, you'll note the optionally installed 32768 crystal on pins 19,20 of the MCU.

https://www.pjrc.com/teensy/schematic.html

Many MCUs of varied type have that option for the crystal.
If installed, software can enable the oscillator controlled by the 32768 crystal and utilize the MCU's real time clock / calendar (RTC), for keeping date/time. Data logging is one example where the MCU is battery powered and must "sleep" by software command to extend battery life. The RTC oscillator can keep running so that date/time is kept even in very low power sleep-state. So long as the battery isn't depleted. The RTC oscillator is powered by VBAT on pin 21 which uses USB 3 power if available, else externally applied VBAT from a small coin cell is often used. Setting the RTC at first use requires some external communications or a human temporarily in the loop, etc.

The 32768 frequency is because long ago, digital watches and time keeping devices chose that frequency for simplicity in time keeping. The crystals are thus low cost.

You can read more about the RTC in the data sheet for the MCU.

Teensy 3 and other MCUs have this as well.
Some MCUs don't have an on-board RTC and an external RTC chip is added to the project and wired to the MCU.

Network attached (ethernet or WiFi) MCUs can get date/time from internet time severs rather than the hardware RTC.
 
Last edited:
On the schematic, you'll note the optionally installed 32768 crystal on pins 19,20 of the MCU.

https://www.pjrc.com/teensy/schematic.html

Many MCUs of varied type have that option for the crystal.
If installed, software can enable the oscillator controlled by the 32768 crystal and utilize the MCU's real time clock / calendar (RTC), for keeping date/time. Data logging is one example where the MCU is battery powered and must "sleep" by software command to extend battery life. The RTC oscillator can keep running so that date/time is kept even in very low power sleep-state. So long as the battery isn't depleted. The RTC oscillator is powered by VBAT on pin 21 which uses USB 3 power if available, else externally applied VBAT from a small coin cell is often used. Setting the RTC at first use requires some external communications or a human temporarily in the loop, etc.

The 32768 frequency is because long ago, digital watches and time keeping devices chose that frequency for simplicity in time keeping. The crystals are thus low cost.

You can read more about the RTC in the data sheet for the MCU.

Teensy 3 and other MCUs have this as well.
Some MCUs don't have an on-board RTC and an external RTC chip is added to the project and wired to the MCU.

Network attached (ethernet or WiFi) MCUs can get date/time from internet time severs rather than the hardware RTC.

I believe you have the wrong pins on the schematic the way it looks its pin 18/19 and pins 36/37 when programming. So what I'm getting from what you said is anything that needs a RTC you add that crystal to the Teensy. Is this right way to think?
 
I may have misunderstood... we're talking about Teensy, not Teensy 3, right?
And Teensy++ 2 allows for a 32768MHz crystal, per its schematic (scroll down to it).

Yes, that grey-out crystal on the Teensy++ 2 schematic would be added. Or you wire up an external RTC chip as described on PJRC's web site of examples. Or forego the RTC and keep time with the standard 1KHz interrupt clock but you have to manually (human) set the time each power-up.
 
Last edited:
What is the 32768 Hz crystal used for when it is attached to the Teensy 2.0 ++?

One of the timers in that chip supports an asynchronous mode, where the timer can use a crystal to keep it running while the chip is in sleep mode.

What type of projects need this extra crystal for?

None. Or not much, to be honest.

At least as far as I know, in the entire history of Teensy++ 2.0, nobody has actually used that feature. Or if they have, I never heard any feedback about it. Several times this question about what it could do has some up, and many people have soldered a crystal onto their board, but so far there's never been any sign anyone actually tried create the code to actually use it.

Realistically, this just isn't a really useful feature, because there isn't any hardware capability to add a battery to keep it running while the main power is off. But if you really want to try using it, the timer hardware is documented in Atmel's datasheet. I haven't personally used this feature, but if you do try and run into issues, post a question on the forum (and follow the "forum rule") and I'll try to help.

If you want an RTC, using Teensy 3.2 is a much better path. It does have real RTC features for the extra crystal. If you really want to stay with Teensy++ 2.0, using a RTC chip is probably a much better plan.
 
One of the timers in that chip supports an asynchronous mode, where the timer can use a crystal to keep it running while the chip is in sleep mode.



None. Or not much, to be honest.

At least as far as I know, in the entire history of Teensy++ 2.0, nobody has actually used that feature. Or if they have, I never heard any feedback about it. Several times this question about what it could do has some up, and many people have soldered a crystal onto their board, but so far there's never been any sign anyone actually tried create the code to actually use it.

Realistically, this just isn't a really useful feature, because there isn't any hardware capability to add a battery to keep it running while the main power is off. But if you really want to try using it, the timer hardware is documented in Atmel's datasheet. I haven't personally used this feature, but if you do try and run into issues, post a question on the forum (and follow the "forum rule") and I'll try to help.

If you want an RTC, using Teensy 3.2 is a much better path. It does have real RTC features for the extra crystal. If you really want to stay with Teensy++ 2.0, using a RTC chip is probably a much better plan.

I wasn't going to use it I was just curious if it is even useful at all. Which what I got from what you said is its just an abandon Idea that no one has ever used (or at least posted about.)
 
On the Teensy ++2.0, I'd like to give the 32khz crystal a try. Can I use the FlexiTimer2 library to use the crystal? I'm using SPI, OneWire, EEPROM, Bounce2, openGLCD and Ethernet libraries. Are there any timer conflicts?
 
You'll need to use the timer2 hardware registers to access the special mode for the crystal.

As far as I know, none of those libs use timer2, so you shouldn't have any conflicts. But you should also be aware the a sync crystal feature is rarely useful. It doesn't keep running while power is off. Unless you're using the AVR sleep mode, it's unlikely to be of much practical use.

The optional crystal for Teensy 3.2 actually does work as a RTC.
 
Currently, data from the teensy gets sent to a desktop PC. Part of the data is the current time on the teensy. If the time is more than a few seconds off, the correct time is sent to the teensy. This has worked well for quite some time - years. Time updates were many days apart. Now the time updates are minutes apart. Nothing has changed. Hardware or software. So I'm looking for a better way to implement a RTC with no hardware changes.
All the pins on the teensy are used up except for the ones in the middle of the board.

Time is kept by a function that gets called in the loop() function. After approx 1000milliseconds go by the clock is updated. Perhaps this is not the best way to do this?

Adding a crystal and 2 caps to the bottom of the teensy along with a few lines of code seemed like the easiest solution. But perhaps I'm missing something?

Code snippets of how it currently works:

time_t MillisPerSec = 990UL;
...........
cur_millis = millis();

/* every second */
if(cur_millis - sec_millis >= MillisPerSec)
{
sec_millis = cur_millis;

UnixTime++;
SetTime(); /* fill the hwtime struct */
}
===========
You'll need to use the timer2 hardware registers to access the special mode for the crystal.

As far as I know, none of those libs use timer2, so you shouldn't have any conflicts. But you should also be aware the a sync crystal feature is rarely useful. It doesn't keep running while power is off. Unless you're using the AVR sleep mode, it's unlikely to be of much practical use.

The optional crystal for Teensy 3.2 actually does work as a RTC.
 
Status
Not open for further replies.
Back
Top