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

Thread: SPI in 32 bit data TX

  1. #1

    SPI in 32 bit data TX

    is there a way to configure the SPI to send 32bits without braking it up?
    #include <SPI.h>


    // set pin 10 as the slave select for the digital pot:
    const int slaveSelectPin = 10;
    long DATA =0;
    void setup() {
    // set the slaveSelectPin as an output:
    pinMode (slaveSelectPin, OUTPUT);
    digitalWrite (slaveSelectPin, HIGH);
    // initialize SPI:
    SPI.begin();
    SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
    }

    void loop() {

    delay(1);
    digitalWrite(slaveSelectPin,LOW);
    SPI.transfer(DATA);
    SPI.transfer(DATA);
    SPI.transfer(DATA);
    SPI.transfer(DATA);
    digitalWrite(slaveSelectPin,HIGH);

    }

  2. #2
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,530
    The answer is no, at least for the Teensy 3.x. The SPI transmit data register can hold a maximum of 16bit. But there is a configuration flag for continuous mode, so that you can transmit your 32bit value as 2x16bit with (almost) no gap.
    But if I remember well, neither 16bit nor continuous mode are supported by the standard (Arduino compatible) SPI library. Either you find an optimized library for the T3.x or you implement these yourself after studying the SPI chapter of the processor reference manual.

Posting Permissions

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