Teensy 4.0 hardware timers for PWM and pins

Paul L

Member
Could someone tell me how many PWM timers the Teensy 4.0 has and the respective pins? I'm looking for something like this that I got from the PWM and Tone link for the Teensy 3.6:

FTM0 5, 6, 9, 10, 20, 21, 22, 23 488.28 Hz
FTM1 3, 4 488.28 Hz
FTM2 29, 30 488.28 Hz
FTM3 2, 7, 8, 14, 35, 36, 37, 38 488.28 Hz
TPM1 16, 17 488.28 Hz

Thanks,
Paul
 
Hopefully someone will have the exact information you are looking for.

Also not sure from your question what information are you really wanting or needing. For example if you are simply wanting to to use analogWrite, then simply looking at the reference card for the T4 should give you most of the details you need. Now if your question is something like: can I do N pins of PWM output at some speed, then you need additional information, or if you simply want to know which actual timers are used for what, then you might need other information.

But in the meantime hopefully you can extract some maybe most of the information from some of the following:

There are lots of timers and the like: How many pins support PWM?

One way is to look at the card that ships with the T4 which marks all of the PWM pins.
You can also see this card up at: https://www.pjrc.com/teensy/pinout.html

There is also lots of information in post #3 of the beta thread for T4: https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test?p=193716&viewfull=1#post193716
Which has table showing which timer and the like is connected to each of the pins.

There is lots of information on each of these timers up in the datasheet, which you can download from: https://www.pjrc.com/teensy/datasheets.html

As for the clock speeds, many of them depend on how they are configured. So for example most every time I am up trying to figure out the timings and settings for things, like how fast can SPI go or the like, I have to start off looking at the CCM Clock tree which I think I have the version of IMXRT1060RM up on pjrc, is on page 1072 (Section 13.4)

Sections 50-58 describe the different timers that are on the T4. For example chapter 54 describes the eFlexPWM system...

But if it were me, the first thing I would do is to look at the code: For example if you look at the latest released Teensyduino and look at the file cores\teensy4\pwm.c
Or the most up to date version (not yet released) you can look up on github in @PaulStoffregen core project:
https://github.com/PaulStoffregen/cores/blob/master/teensy4/pwm.c#L19

If you look at the array pwm_pin_info It shows which timers are used for which PWM pin.
And farther down if you look at the actual code for analogWrite, you can walk through to see how it handles configuring each of these types of timers.

Hope that helps a little,

Kurt
 
Thanks Kurt, I'll look into it.

Right now I'm generating a PWM on one timer, and reading the duty cycle on 4 independant freqencies on the 4 other pins as follows:

Wheelspeed : FTM3 pin2
Input frequency 1: pin5
Input frequency 2: pin6
Input frequency 3: pin22
Input frequency 4: pin23

When I wrote my first question, I was thinking that the "FreqMeasureMulti" library needed a separate timer for each input frequency, but since it can handle 8 inputs, that may not be the case. I was confusing it with generating different frequencies. I may want to eventually output than one frequency, so the basically my question is whether or not the Teensy 4.0 has more timers than the Teensy 3.6, and therefore more PWM output capability.
 
Dear all,

The code is used with a Teensy 3.2 but I like to use a Teensy 4.0 I think a Teensy 4.0 has different timers?

Please help .....

Best regards,
Johan

Code:
#ifdef ___TEENSY
    #define BOARD_LED_PIN 13
    pinMode(BOARD_LED_PIN, OUTPUT);
    pinMode(OLED_MOSI,  OUTPUT);
    pinMode(OLED_CLK,   OUTPUT);
    pinMode(OLED_DC,    OUTPUT);
    pinMode(OLED_RESET, OUTPUT);
    pinMode(OLED_CS,    OUTPUT);
    analogReadRes(12);

    SIM_SCGC6 |= SIM_SCGC6_PIT;           // CONFIGURE TIMERS
    SIM_SCGC6 |= SIM_SCGC6_FTM0;
    //PIT_MCR = 0x00;
    //NVIC_ENABLE_IRQ(IRQ_PIT_CH0);
  #endif
 
The question is how can change this
SIM_SCGC6 |= SIM_SCGC6_PIT; // CONFIGURE TIMERS
SIM_SCGC6 |= SIM_SCGC6_FTM0;
for a Teensy 4.0 I looked already to link timing but I have no clue....
Best regards,
Johan
 
Back
Top