Servo/Tone under Teensy 3.0

Status
Not open for further replies.

MichaelMeissner

Senior Member+
I was updating the text table I have to keep track of what pins do what for the Arduino Uno and Teensy 3.0 (I also have digispark, but so far, I haven't actually done anything with the spark). I added notes for the Uno that using the tone library will disable PWM on pins 3 and 11, and using the servo library will disable PWM on pins 9 and 10. In looking at the Teensy 3.0 library links, I did find not any such restrictions. I assume that due to the fact that Arm has very different interrupts than the AVR, that tone/servo don't cause PWM to stop working on any pins on Teensy 3.0. Is this correct?

Here is the table in case it would be helpful to other people:
Code:
// Standard output pin assignments
//
//              Arduino Uno                     Teensy 3.0                                      Digispark
//              ===========                     ==========                                      =========
//              A/D | PWM | I2C/SPI  | Other    A/D | PWM | Serial  | I2C/SPI  | Other          A/D | PWM | I2C | Other
//              ====+=====+==========+=======   === +=====+=========+==========+======          ====+=====+=====+======
// Pin 0:       D   | --- | --       | RX       D   | --- | RX/RX1  | --       | Touch          D   | Yes | SDA | --
// Pin 1:       D   | --- | --       | TX       D   | --- | TX/TX1  | --       | Touch          D   | Yes | --- | LED,  *3
// Pin 2:       D   | --- | --       | Int2     D   | --- | --      | alt CS0  | ---            AD  | --- | SCK | --
// Pin 3:       D   | *1  | --       | Int3     D   | Yes | --      | --       | ---            AD  | --- | --- | USB+, *4
// Pin 4:       D   | --- | --       | --       D   | --- | --      | --       | ---            AD  | Yes | --- | USB-
// Pin 5:       D   | Yes | --       | --       D   | Yes | Alt Tx1 | --       | ---            AD  | --- | --- | --
// Pin 6:       D   | Yes | --       | BRx, *5  D   | Yes | --      | alt CS1  | ---
// Pin 7:       D   | --- | --       | BTx, *5  D   | --- | RX3     | alt MOSI | ---
// Pin 8:       D   | --- | --       | --       D   | --- | TX3     | alt MISO | ---
// Pin 9:       D   | *2  | --       | --       D   | Yes | RX2     | SPI CS1  | --
// Pin 10:      D   | *2  | SPI SS   | --       D   | Yes | TX2     | SPI CS0  | --
// Pin 11:      D   | *1  | SPI MOSI | --       D   | Yes | --      | SPI MOSI | --
// Pin 12:      D   | Yes | SPI MISI | --       D   | Yes | --      | SPI MISI | --
// Pin 13:      D   | --- | SPI SCK  | LED      D   | --- | --      | SPI SCK  | LED

// Pin A0/14:   AD  | --- | --       | --       AD  | --- | --      | alt SCK  | --
// Pin A1/15:   AD  | --- | --       | --       AD  | --- | --      | SPI CS4  | Touch
// Pin A2/16:   AD  | --- | --       | --       AD  | --- | --      | alt SCL  | Touch
// Pin A3/17:   AD  | --- | --       | --       AD  | --- | --      | alt SDA  | Touch
// Pin A4/18:   AD  | --- | I2C SDA  | --       AD  | --- | --      | I2C SDA  | Touch
// Pin A5/19:   AD  | --- | I2C SCL  | --       AD  | --- | --      | I2C SCL  | Touch
// PIn A6/20:                                   AD  | Yes | --      | SPI CS2  | --
// Pin A7/21:                                   AD  | Yes | alt RX1 | SPI CS3  | --
// Pin A8/22:                                   AD  | Yes | --      | alt CS3  | Touch
// Pin A9/23:                                   AD  | Yes | --      | alt CS2  | Touch

// *1 On the Uno, the Tone library will interfere with analogWrite (PWM) on pins 3 & 11.
//
// *2 On the Uno, the Servo library disables analogWrite (PWM) on pins 9 & 10 whether or
// not there is a servo on those pins
//
// *3 Digispark pin 1 has a weak input resistor
//
// *4 Digispark pin 3 has a 1.5 kΩ pull-up resistor attached to it which is
// required for when P3 and P4 are used for USB communication (including
// programming). Your design may need to take into account that you'd have to
// overpower this to pull this pin low.
//
// *5 The Uno bluetooth shield uses pins 6 (receive) and 7 (transmit) by default.
// It can use pins 0 and 1 if jumpered to do so.
:cool:
 
In looking at the Teensy 3.0 library links, I did find not any such restrictions. I assume that due to the fact that Arm has very different interrupts than the AVR, that tone/servo don't cause PWM to stop working on any pins on Teensy 3.0. Is this correct?

Yes, absolutely correct.

On Teensy3, tone() uses IntervalTimer, which uses one of the 4 PIT timers that are completely separate from the PWM hardware. Servo uses the PDB (Programmable Delay Block), which is yet another timer that's separate from the PWM hardware.

Teensy3 has 8 timers that are completely separate from the times that generated PWM. They are the 4 PIT (IntervalTimer), PDB (Servo), CMT (IRremote), SysTick (millis), and LPTMR (not currently used by any code, as far as I know).
 
Maybe add Teensy 3.0 A10..A13 and pins 24..33 as well?

Well its for my own reference of the boards I own, so that in a design that changes over time, I can choose simple digital pins to avoid pins that might have special uses. For example avoiding RX1/TX1 or RX2/TX2 if I wanted to add bluetooth support. Or in the Arduino case, knowing which PWM pins can't be used if I use certain libraries.

At the moment, I bought 2 Teensy's with the pins soldered in, so I don't have convenient access to the pins underneath. If/when I run out of pins, I've been thinking of getting one the teensy 3.0 dip/extender adapters that joni and Tall Dog LLC sell over at tindie.com, but I would probably want to to buy a Teensy 3.0 without the pins being soldered to use those boards. When that happens, I will revise the text.
 
Status
Not open for further replies.
Back
Top