Component selection

Colorado

Member
All,

I want to build a custom board using the pjrc bootloader chip along with the microcontroller used on a teensy 4.1. I'm building out the schematic in KiCad and I'm wondering how i should go about selecting the right capacitors/resistors/crystal oscillators/inductors. Capacitor selection seems a bit more straight forward (select the right capacitance and voltages for the caps). For resistors it's not always obvious to me what wattage values I should be using for the resistors. I plan on having the board made with all SMD/SMT components since i don't want to be soldering anything.

Am I just not grooming through the datasheets for said components (bootloader chip/microcontroller) and etc well enough?

Thanks in advance.
 
For 3.3V logic, you won't have to worry about resistor dissipation, even a 200 ohm resistor can be 0603 without thermal issues.
P = V^2/R, so for 3.3V that means P = 10/R roughly.
 
For 3.3V logic, you won't have to worry about resistor dissipation, even a 200 ohm resistor can be 0603 without thermal issues.
P = V^2/R, so for 3.3V that means P = 10/R roughly.
Makes perfect sense. Didn't occur to me that i should be using ohm's law. Doesn't help that I've spent far more of my career being a software engineer than an electrical (if I ever was one).

For the crystals 23.768kHz and 24M Hz I've seen notes that they are just normal 20PPM. Digging through the MIMXRT1062DVJ6B documentation it mentions that the RTC crystal should be "if the user wishes to configure RTC_XTALI and RTC_XTALO as an RTC oscillator, a 32.768 kHz
crystal, (less than or equal to100 kOhm ESR, 10 pF load) should be connected between RTC_XTALI and RTC_XTALO. Keep in mind the capacitors implemented on either side of the crystal are about twice the crystal load capacitor.
" so I would assume that I should pick a 10pF load capacitance crystal for the RTC but I'm not sure what the maximum drive level would be. Per Mouser there's only two crystals I can pick .5uW or 1uW so i'm guessing either or is likely fine?

For the 24 MHz crystal the documentation states "A 24.0 MHz crystal should be connected between XTALI and XTALO. The crystal must be rated for a maximum drive level of 250 uW. " I assume a crystal rated at 300uW drive level will work and 6pF load capacitance?
 
You have 2 basic options for the crystal and capacitor choice. Many people just pick pretty much any random crystal with the desired frequency and use 22 pF capacitors. If you get the capacitors "wrong", usually the crystal oscillator will still work but have the frequency slightly off. Many people don't really care. I suspect many of the Adafruit, Sparkfun and other common dev boards are designed this way.

I definitely care about get the crystal as accurately tuned as feasible. Unfortunately the actual capacitance is the sum of capacitors you use plus capacitance of the pins and PCB traces. Typically the PCB doesn't add much, but the chip definitely does. Sadly, NXP doesn't give good specs, so getting the capacitors tuned will involves careful testing.

For Teensy 4.0 and Teensy 4.1, quite a lot of testing was done by soldering many different capacitors on about a dozen test boards. It turns out the pins for the 24 MHz crystal have much more capacitance inside the chip than the pins for the 32 kHz oscillator. Why, I don't know. Only people at NXP familiar with the analog design inside the chip could say, and of course companies like NXP almost never disclose those sorts of details.

To experimentally verify the capacitor selection, you need to run special programs which output the clocks as digital signals, so you can measure them with a frequency counter. Measuring at the crystal isn't feasible, since even with a very expensive active probe, you'll alter the capacitance by touching the test probe to the circuit. Fortunately the IMXRT chip has hardware features to output the clocks on specific pins. For 24 MHz you get a few different possible pins. For 32 kHz isn't only possible at 1 place, called "AD_B0_00" in NXP's documentation. Every Teensy 4.0 & 4.1 has a test pad connected to that location, specifically for this sort of testing and used used in production for a quicker low precision measurement to verify the 32 kHz crystal is working.

Here's a program which turns on both, and implements a simple frequency counter in software for convenience.


Code:
// Measure at:
//  Teensy 4.0 - Test pad closest to pin 19
//  Teensy 4.1
//  MicroMod

uint32_t prior_count = 0;
volatile uint32_t counter = 0;
elapsedMillis timeout = 0;

void inc() {
        counter++;
}

void setup() {
        // REF_CLK_24M pins: (page 1132)
        // GPIO_AD_B0_01 ALT2 not connected
        // GPIO_AD_B0_03 ALT6 Pin 0  <--- use this pin
        // GPIO_AD_B0_13 ALT7 Pin 25
        IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03 = 6;

        // Output 32 kHz to test pad on bottom side of Teensy 4.0 / 4.1
        IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_00 = 2; // REF_CLK_32K, pg 469

        // Measure frequency on pin 2
        pinMode(2, INPUT_PULLDOWN);
        attachInterrupt(2, inc, FALLING);
        timeout = 0;
}

void loop() {
        if (timeout >= 1000) {
                timeout -= 1000;
                uint32_t count = counter;
                Serial.print("pin 2 = ");
                Serial.print(count - prior_count);
                Serial.println(" Hz");
                prior_count = count;
        }
}

Of course to check the capacitors for the oscillator's accuracy, you should use a proper frequency counter. PJRC has a BK Precision 1823A with an external 10 MHz GPS disciplined reference oscillator. Almost any lab bench frequency counter can work. But few of them have really high quality reference, so almost all have a BNC jack where you connect a high quality 10 MHz reference for the cases where you need a highly accurate measurement.

I know this isn't the simple answer you probably wanted. But the sad reality is the IMXRT chip just doesn't come with good enough specs to only use math. Your choices are to just use common parts and accept it'll "work" but not be tuned as accurately, or to build up test units and carefully verify while testing with different capacitors.
 
You have 2 basic options for the crystal and capacitor choice. Many people just pick pretty much any random crystal with the desired frequency and use 22 pF capacitors. If you get the capacitors "wrong", usually the crystal oscillator will still work but have the frequency slightly off. Many people don't really care. I suspect many of the Adafruit, Sparkfun and other common dev boards are designed this way.

I definitely care about get the crystal as accurately tuned as feasible. Unfortunately the actual capacitance is the sum of capacitors you use plus capacitance of the pins and PCB traces. Typically the PCB doesn't add much, but the chip definitely does. Sadly, NXP doesn't give good specs, so getting the capacitors tuned will involves careful testing.

For Teensy 4.0 and Teensy 4.1, quite a lot of testing was done by soldering many different capacitors on about a dozen test boards. It turns out the pins for the 24 MHz crystal have much more capacitance inside the chip than the pins for the 32 kHz oscillator. Why, I don't know. Only people at NXP familiar with the analog design inside the chip could say, and of course companies like NXP almost never disclose those sorts of details.

To experimentally verify the capacitor selection, you need to run special programs which output the clocks as digital signals, so you can measure them with a frequency counter. Measuring at the crystal isn't feasible, since even with a very expensive active probe, you'll alter the capacitance by touching the test probe to the circuit. Fortunately the IMXRT chip has hardware features to output the clocks on specific pins. For 24 MHz you get a few different possible pins. For 32 kHz isn't only possible at 1 place, called "AD_B0_00" in NXP's documentation. Every Teensy 4.0 & 4.1 has a test pad connected to that location, specifically for this sort of testing and used used in production for a quicker low precision measurement to verify the 32 kHz crystal is working.

Here's a program which turns on both, and implements a simple frequency counter in software for convenience.


Code:
// Measure at:
//  Teensy 4.0 - Test pad closest to pin 19
//  Teensy 4.1
//  MicroMod

uint32_t prior_count = 0;
volatile uint32_t counter = 0;
elapsedMillis timeout = 0;

void inc() {
        counter++;
}

void setup() {
        // REF_CLK_24M pins: (page 1132)
        // GPIO_AD_B0_01 ALT2 not connected
        // GPIO_AD_B0_03 ALT6 Pin 0  <--- use this pin
        // GPIO_AD_B0_13 ALT7 Pin 25
        IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_03 = 6;

        // Output 32 kHz to test pad on bottom side of Teensy 4.0 / 4.1
        IOMUXC_SW_MUX_CTL_PAD_GPIO_AD_B0_00 = 2; // REF_CLK_32K, pg 469

        // Measure frequency on pin 2
        pinMode(2, INPUT_PULLDOWN);
        attachInterrupt(2, inc, FALLING);
        timeout = 0;
}

void loop() {
        if (timeout >= 1000) {
                timeout -= 1000;
                uint32_t count = counter;
                Serial.print("pin 2 = ");
                Serial.print(count - prior_count);
                Serial.println(" Hz");
                prior_count = count;
        }
}

Of course to check the capacitors for the oscillator's accuracy, you should use a proper frequency counter. PJRC has a BK Precision 1823A with an external 10 MHz GPS disciplined reference oscillator. Almost any lab bench frequency counter can work. But few of them have really high quality reference, so almost all have a BNC jack where you connect a high quality 10 MHz reference for the cases where you need a highly accurate measurement.

I know this isn't the simple answer you probably wanted. But the sad reality is the IMXRT chip just doesn't come with good enough specs to only use math. Your choices are to just use common parts and accept it'll "work" but not be tuned as accurately, or to build up test units and carefully verify while testing with different capacitors.

Paul,

Thanks for the early response!

While the response isn't exactly what I hoped for, I do appreciate the response. Great to hear that you care about the accuracy and quality of the teensy!

I speculate for what I'm doing (a few simple inputs to the GPIO pins) that I can get away with having the frequency slightly off. Thanks for the key insights since knowledge is power and the more you know the better off you are.
 
Quick test on my SA using a current probe shows 599.9928MHz clock on one of my T4.0's - 12ppm out, which is good for a standard crystal. If higher precision than 20 or 30ppm is desired a TCXO would be the way to go, not trying to tune capacitors, that's only going to work at one temperature for a start. TCXO's can get to stabilities < 1ppm and are extremely cheap these days
 
Back
Top