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.