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

Thread: Teensy 4.0 SPI Clock Speed

  1. #1

    Teensy 4.0 SPI Clock Speed

    I am trying to use the Teensy 4.0 to read an ADC over SPI (data sheet here: https://datasheets.maximintegrated.c...s/MAX11100.pdf)

    The max clock speed for this device is 4 MHz, but the highest SPI divider available through Arduino is 128 giving a SPI clock of 600/128 or 4.68 MHz.

    Any suggestions on how to get around this?

    Thanks in advance,

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Ayer Massachussetts


    Ummm, you should not be using SPI clock dividers as those are deprecated for use on Teensys.

    Instead you should use SPI transactions, which includes a SPIsettings object that you can specify the SPI bus speed, SPI bit order, and the SPI mode directly. On a 3.5, I used this to tune a SPI display to different spi speeds from 8Mhz to 21Mhz (19Mhz was the sweet spot for that particular configuration, until I put in pull-up resistors on the CS/DC pins).

    In particular:

    Transactional SPI configuration
    A common problem used to be that different SPI devices needed different, incompatible settings. Your sketch had to take care of saving and restoring the SPI settings before communicating with each SPI device. If any SPI device was accessed from an interrupt, this could result in data corruption if another SPI device was communicating at the time.

    With the new SPI library, configure each SPI device once as an SPISettings object. Also, if that device will be called from an interrupt, say so with SPI.usingInterrupt(interruptNumber). To communicate with a specific SPI device, use SPI.beginTransaction which automatically uses the settings you declared for that device. In addition, it will disable any interrupts that use SPI for the duration of the transaction. Once you are finished, use SPI.endTransaction() which re-enables any SPI-using interrupts.

  3. #3
    Hey Michael,

    This fixed it thanks!

    I guess it goes without saying that I'm new to Teensy

Posting Permissions

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