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

Thread: Teensy Quick Reference: Code Examples, Tips and Tricks

Threaded View

  1. #1
    Senior Member
    Join Date
    Oct 2012
    Portland OR

    Teensy Quick Reference: Code Examples, Tips and Tricks

    The information below generally applies to Teensy 3.0, 3.1 and 3.2, unless otherwise noted.

    ---------------- FREQUENTLY ASKED QUESTIONS --------------------

    Why can't my PC see or program my Teensy? Make sure you have a full USB cable and not a 2-wire charging-only cable.

    How to completely erase a T3.x? Press program button for exactly 15 seconds (+/- 2 sec)

    What is the PWM frequency range and resolution?

    What Timers are available? (12, in hardware)

    What is the internal reference voltage? (1.2V on T3, 2.56V on T2, none on LC)

    How fast is the DAC?

    Are lock bits supported? Can I run T3.1 at 72 MHz?

    Can I use Teensy in a commercial product?
    ...and also

    Where are the Teensy pinouts?

    How much drive current at pin? (9 mA, 25 mA abs.max)

    Where are the Teensy [1,2,3] schematics?

    Where are the CPU datasheets?

    Can I overclock beyond 96 MHz? (yes, just edit your "boards.txt")
    For example, uncomment "# MHz optimized (overclock)" in C:\Program Files (x86)\Arduino\hardware\teensy\avr\boards.txt

    How can I wire USB into Teensy without a connector?

    How can code tell which Teensy is selected at compile time?

    ---------------- CODE EXAMPLES --------------------

    printf / scanf with floating point (otherwise not enabled as of Teensyduino 1.21 )

    Better choices for timing than delay()

    Using the built-in watchdog timer (changes mk20dx128.c )

    Restart CPU without reboot

    Reset and Reboot

    Read/Write 8 bits in parallel

    Setting an I/O pin to Open Drain

    Increase I/O Slew Rate (default = 7 ns, fast = 0.85 ns)

    Capacitive Touch Sensing example using touchRead()
    T3/T3.1 touch sensing pins are: 0, 1, 25, 32, 33, A1, A2, A3, A4, A5, A8, and A9

    Waveform generation from table using DAC and PDB (T3.1)

    Complementary PWM output with settable dead time:

    Edge capture with DMA from user 'tni'

    Measure noise level of 16-bit ADC

    Readout MAC Address

    128-bit unique identification (ID) number per chip

    Compile Time information

    Software reboot

    Waking up a USB host computer

    Inline Assembly

    Coding in Assembly (separate ASM file)

    MicroSD Card Guide

    Remap SCK from Pin 13

    Double precision constants must end with 'L' otherwise they are made into single-precision floats

    Note that analogWrite() goes from 0 up to 256, not 255.

    Mouse Boot Protocol

    ---------------- LIBRARIES --------------------

    List of Teensy Libraries

    SdFat Beta library support for T3.5/3.6 SDIO

    DMA SPI library

    High-speed I2C library (Wire & Wire1)

    ADC Library by Pedvide

    Entropy Library for Random Numbers from Timers

    Low Power Library (Beta) (Sleep, DeepSleep, Hibernate)

    Snooze (Duff's low power library)
    All Things Low Power

    Audio Library (Beta) for T3 Audio Adapter Board
    Change ADC/DAC sample rate

    FastLED Library for LED strips: WS2810, WS2811, LPD8806, Neopixel... and

    Artnet for OctoWS2811 LED strips (DMX over Ethernet) (needs WIZ820io + T3 adaptor ) :

    Interval Timer using interrupts
    See also: Metro Library and ElapsedMillis
    (older "Periodic Interrupt Timer Library" now depreciated?)

    Pulse Position Library 0.02 us precision Tx/Rx (T3.1)

    CAN Bus Library (T3.1)

    USB Host Library
    ...and also

    Simple Task Library

    Teensy 2 Libraries

    C++ STL (Standard Template Library)

    ---------------- HARDWARE SHIELDS & ADD-ONS --------------------

    Hardware mods to operate T3.2 on 1.8V

    Pinouts of Teensy 3.x and other boards

    Using All Teensy3.x Pins with a Socket
    Breakout All Teensy3.x Pins
    Teensy 3.1 Sheilds

    PJRC's Prop Shield (10 axis+audio,LED drv.)
    PJRC's audio adapter
    PJRC's WIZ820io and SD card adapter
    PJRC's Octows2811 (neopixel) adapter
    PJRC's double high breakaway pins for shields needing more clearance
    PJRC's 14 pin female header socket
    KurtE's Teensy 3.1 breakout board
    TallDog's breakout board to access all pins
    Pico's Teensy 3.x to Arduino shield + nRF24L01+ radio breakout
    Pesky Products LSM9DS0 micro T3.x shield (9 axis)
    Pesky Products LSM9DS0 mini T3.x shield (9 axis + ALT)
    Petit Studio's Teensy 3.x development board and Arduino shield (all pins)
    Pixelmatrix's SmartMatrix shield for 16x32 and 32x32 LEDs (Adafruit also)

    ---------------- DEV TOOLS --------------------

    TyQT for more than one Teensy on a PC

    Developing with Eclipse

    Optimizing code size (FLASH space)

    PC Host communication: USB Latency Test discussed in

    Oscilloscope advice:

    ---------------- PCB LAYOUT TOOLS --------------------

    There are many options, but some free-of-charge versions are often used to do open hardware:

    Eagle CAD most often used(?)
    Design Spark PCB shows ads
    DipTrace (free ver: 300 pin limit)
    KiCad open source, unrestricted
    Fritzing simple/easy for beginners
    Last edited by JBeale; 01-09-2018 at 08:15 PM. Reason: add tni's DMA capture example

Tags for this Thread

Posting Permissions

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