Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Timer1, Timer3 and PWM

  1. #1

    Timer1, Timer3 and PWM

    Hi just wondering why the Timer1 and Timer3 library only works with pins 3,4 and 29,30 but analogueWrite on the Teensy 2.6 works on pins 5, 6, 9, 10, 20, 21, 22, 23 ( Timer FTM0) and 2, 7, 8, 14, 35, 36, 37, 38 (Timer FTM3).

    I would like to use the Timer1/Timer3 libraries to get the Timer1.attachInterrupt(function) capability but on more the the 4 pins above.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,380
    Probably controlled/limited by the feature/connect/design of the microcontroller internals. Generally those are hardware constraints, not a failure to provide features when possible.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,929
    As you can probably guess, those 2 libraries are accessing the FTM1 and FTM2 timers.

    If you want to have essentially the same library code accessing the FTM0 or FTM3 timer, you'll need to make a copy of the library and edit the code. By comparing the code of the 2 existing libraries (maybe first delete all the non-Teensy code from both), you can pretty easily see which code is common to both and where names differ. Just edit all those differing places in your 3rd copy of the library, so it accesses FTM0 or FTM3. Easy, right?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •