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
    Location
    Portland OR
    Posts
    593

    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)
    https://forum.pjrc.com/threads/37531...l=1#post116941

    What is the PWM frequency range and resolution? http://www.pjrc.com/teensy/td_pulse.html

    What Timers are available? (12, in hardware) https://forum.pjrc.com/threads/28714...ll=1#post73823

    What is the internal reference voltage? (1.2V on T3, 2.56V on T2, none on LC)
    https://forum.pjrc.com/threads/35446...ltage-Question

    How fast is the DAC? https://forum.pjrc.com/threads/26036...ll=1#post49821

    Are lock bits supported? Can I run T3.1 at 72 MHz? http://forum.pjrc.com/threads/25407-...ll=1#post44401

    Can I use Teensy in a commercial product? http://forum.pjrc.com/threads/799-Fi...ull=1#post1783
    ...and also http://forum.pjrc.com/threads/24063-...ll=1#post34451

    Where are the Teensy pinouts? http://www.pjrc.com/teensy/pinout.html

    How much drive current at pin? (9 mA, 25 mA abs.max)
    https://forum.pjrc.com/threads/5455-...nt-per-I-O-pin

    Where are the Teensy [1,2,3] schematics? http://www.pjrc.com/teensy/schematic.html

    Where are the CPU datasheets? https://www.pjrc.com/teensy/datasheets.html

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

    How can I wire USB into Teensy without a connector? https://forum.pjrc.com/threads/19336...-USB-connector

    How can code tell which Teensy is selected at compile time? https://forum.pjrc.com/threads/25395...ll=1#post94035

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

    printf / scanf with floating point (otherwise not enabled as of Teensyduino 1.21 )
    https://forum.pjrc.com/threads/27827...-on-Teensy-3-1

    Better choices for timing than delay() https://www.pjrc.com/teensy/td_timing.html

    Using the built-in watchdog timer (changes mk20dx128.c ) http://forum.pjrc.com/threads/25370-...ll=1#post44197

    Restart CPU without reboot http://forum.pjrc.com/threads/24304-...5253#post45253

    Reset and Reboot http://forum.pjrc.com/threads/24304-...nsyduino%28%29
    http://forum.pjrc.com/threads/25306-...ll=1#post45344

    Read/Write 8 bits in parallel https://forum.pjrc.com/threads/17532...ll=1#post21228

    Setting an I/O pin to Open Drain http://forum.pjrc.com/threads/25393-...ll=1#post44249

    Increase I/O Slew Rate (default = 7 ns, fast = 0.85 ns) https://forum.pjrc.com/threads/28735...ll=1#post75044

    Capacitive Touch Sensing example using touchRead() http://dangerousprototypes.com/forum...?t=4606#p45520
    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) http://forum.pjrc.com/threads/25275-...ll=1#post43873

    Complementary PWM output with settable dead time: http://forum.pjrc.com/threads/24992-...ll=1#post44563

    Edge capture with DMA from user 'tni'
    https://forum.pjrc.com/threads/37148...l=1#post124805

    Measure noise level of 16-bit ADC http://forum.pjrc.com/threads/25111-...ll=1#post42891

    Readout MAC Address http://forum.pjrc.com/threads/91-teensy-3-MAC-address

    128-bit unique identification (ID) number per chip https://forum.pjrc.com/threads/25522...ll=1#post72175

    Compile Time information https://forum.pjrc.com/threads/25395...l=1#post116099

    Software reboot http://forum.pjrc.com/threads/24304-...nsyduino%28%29

    Waking up a USB host computer https://forum.pjrc.com/threads/26649...h-a-teensy-3-0

    Inline Assembly http://forum.pjrc.com/threads/25317-...ll=1#post43724

    Coding in Assembly (separate ASM file) https://forum.pjrc.com/threads/27938...3-1-or-Teensy2

    MicroSD Card Guide http://forum.pjrc.com/threads/16758-...-MicroSD-guide

    Remap SCK from Pin 13 http://forum.pjrc.com/threads/25349-Remapping-pin-13

    Double precision constants must end with 'L' otherwise they are made into single-precision floats
    https://forum.pjrc.com/threads/31233...ll=1#post86850

    Note that analogWrite() goes from 0 up to 256, not 255. https://forum.pjrc.com/threads/33473...ll=1#post99345

    Mouse Boot Protocol https://forum.pjrc.com/threads/33601...-boot-protocol

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

    List of Teensy Libraries http://www.pjrc.com/teensy/td_libs.html

    SdFat Beta library support for T3.5/3.6 SDIO https://github.com/greiman/SdFat-beta https://forum.pjrc.com/threads/36737...l=1#post114355

    DMA SPI library https://github.com/crteensy/DmaSpi https://forum.pjrc.com/threads/27909...ensyduino-1-21

    High-speed I2C library (Wire & Wire1) http://forum.pjrc.com/threads/21680-...ry-for-Teensy3

    ADC Library by Pedvide http://forum.pjrc.com/threads/25532-...for-Teensy-3-1

    Entropy Library for Random Numbers from Timers http://forum.pjrc.com/threads/25369-...ll=1#post44135

    Low Power Library (Beta) (Sleep, DeepSleep, Hibernate) http://forum.pjrc.com/threads/23660-...ll=1#post42776

    Snooze (Duff's low power library) https://github.com/duff2013/Snooze
    All Things Low Power https://forum.pjrc.com/threads/32454...ings-Low-Power

    Audio Library (Beta) for T3 Audio Adapter Board http://forum.pjrc.com/threads/24793-...ll=1#post39468
    https://github.com/PaulStoffregen/Audio
    Change ADC/DAC sample rate https://forum.pjrc.com/threads/45610...l=1#post150049

    FastLED Library for LED strips: WS2810, WS2811, LPD8806, Neopixel... http://fastled.io/ and https://github.com/FastLED/FastLED/wiki/Overview

    Artnet for OctoWS2811 LED strips (DMX over Ethernet) (needs WIZ820io + T3 adaptor ) : http://forum.pjrc.com/threads/24688-...-to-OctoWS2811

    Interval Timer using interrupts http://pjrc.com/teensy/td_timing_IntervalTimer.html
    See also: Metro Library http://pjrc.com/teensy/td_libs_Metro.html and ElapsedMillis http://pjrc.com/teensy/td_timing_elaspedMillis.html
    (older "Periodic Interrupt Timer Library" now depreciated?) http://forum.pjrc.com/threads/17543-...or-Teensy-3-0/

    Pulse Position Library 0.02 us precision Tx/Rx (T3.1) http://www.pjrc.com/teensy/td_libs_PulsePosition.html

    CAN Bus Library (T3.1) http://forum.pjrc.com/threads/25101-...for-Teensy-3-1

    USB Host Library http://www.circuitsathome.com/tag/usb-host-shield
    ...and also http://forum.pjrc.com/threads/13433-...ll=1#post36118

    Simple Task Library https://forum.pjrc.com/threads/33357...E-task-library

    Teensy 2 Libraries https://www.pjrc.com/teensy/td_libs.html

    C++ STL (Standard Template Library) https://forum.pjrc.com/threads/23467...ll=1#post69787

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

    Hardware mods to operate T3.2 on 1.8V https://forum.pjrc.com/threads/35592...l=1#post149208

    Pinouts of Teensy 3.x and other boards https://docs.google.com/spreadsheets...t#gid=95008987

    Using All Teensy3.x Pins with a Socket http://forum.pjrc.com/threads/26071-...-with-a-socket
    Breakout All Teensy3.x Pins https://www.tindie.com/products/logl...y-31-breakout/
    Teensy 3.1 Sheilds http://forum.pjrc.com/threads/25620-...ld-DIY-Adaptor

    PJRC's Prop Shield (10 axis+audio,LED drv.) http://www.pjrc.com/store/prop_shield.html
    PJRC's audio adapter http://www.pjrc.com/store/teensy3_audio.html
    PJRC's WIZ820io and SD card adapter http://www.pjrc.com/store/wiz820_sd_adaptor.html
    PJRC's Octows2811 (neopixel) adapter http://www.pjrc.com/store/octo28_adaptor.html
    PJRC's double high breakaway pins for shields needing more clearance http://www.pjrc.com/store/header_14x1_d.html
    PJRC's 14 pin female header socket http://www.pjrc.com/store/socket_14x1.html
    KurtE's Teensy 3.1 breakout board https://github.com/KurtE/Teensy3.1-Breakout-Boards
    TallDog's breakout board to access all pins https://www.tindie.com/products/logl...y-31-breakout/
    Pico's Teensy 3.x to Arduino shield + nRF24L01+ radio breakout https://www.tindie.com/products/pico...otyping-area-/
    Pesky Products LSM9DS0 micro T3.x shield (9 axis) https://www.tindie.com/products/oneh...-micro-shield/
    Pesky Products LSM9DS0 mini T3.x shield (9 axis + ALT) https://www.tindie.com/products/oneh...1-mini-shield/
    Petit Studio's Teensy 3.x development board and Arduino shield (all pins) https://www.tindie.com/products/fret...rd-and-shield/
    Pixelmatrix's SmartMatrix shield for 16x32 and 32x32 LEDs http://docs.pixelmatix.com/SmartMatrix/shieldref.html (Adafruit also)

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

    TyQT for more than one Teensy on a PC https://forum.pjrc.com/threads/27825...ll=1#post65310

    Developing with Eclipse http://forum.pjrc.com/threads/1474-A...or-development

    Optimizing code size (FLASH space) http://forum.pjrc.com/threads/25196-...-on-Teensy-3-x

    PC Host communication: USB Latency Test discussed in http://forum.pjrc.com/threads/7826-U...ital-I-O-delay

    Oscilloscope advice: http://forum.pjrc.com/threads/25730-...ll=1#post47209

    ---------------- 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(?) http://www.cadsoftusa.com/download-eagle/?language=en
    Design Spark PCB shows ads http://www.rs-online.com/designspark...-pcb-home-page
    DipTrace (free ver: 300 pin limit) http://diptrace.com/downloads/download-diptrace/
    KiCad open source, unrestricted http://www.kicad-pcb.org/display/KIC...Software+Suite
    Fritzing simple/easy for beginners http://fritzing.org/home/
    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
  •