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

Thread: Teensy slave MISO output is always 0x00 using TSPISlave library

  1. #1
    Junior Member
    Join Date
    Aug 2021

    Teensy slave MISO output is always 0x00 using TSPISlave library

    Hey all,

    EDIT: It seems to be a problem with my Teensy. I tried the same code on another one. It works.

    I have been trying to sending some data from Teensy 3.2 to Rasp Pi 4B with Teensy as slave using SPI. I used @tonton81's library. I can send out data from RaspPi and read it in Teensy. However, my main purpose behind doing all this is to push some sensor data that Teensy collects, to RaspPi. Therefore, Teensy writing to RaspPi is what is more important to me and that isn't happening. I used a logic analyser and the MISO pins at the RaspPi is 0x00 always. {Note: MOSI and MISO in this post are all referred to RaspPi. MOSI of Rasp pi is connected to MISO of Teensy and vice versa}. Here are the codes I used at both Master and slave side, along with logic analyser output.

    Master code: RPi

    import time
    import spidev
    spi = spidev.SpiDev(), 1)
    spi.max_speed_hz = 100000 #(100 kHz)
    spi.mode = 0
    print("Beginning bit sweep")
    spi.xfer2([0x20])  # Clear LEDs
        # test = spi.readbytes(2)
        # print(test)
    Slave code: (mostly similar to @tonton8's example in his library. But I'm using 8 bits instead of his 16 bit example)

    #include "TSPISlave.h"
    uint8_t miso = 12;
    uint8_t mosi = 11;
    uint8_t sck = 13;
    uint8_t cs = 10;
    uint8_t spimode = 8;
    TSPISlave mySPI = TSPISlave(SPI, miso, mosi, sck, cs, spimode);
    void setup() {
    void loop() {
    void myFunc() {
      Serial.println("START: ");
      uint8_t arr[2] = { 0x11, 0x22 };
      uint8_t i = 0;
      while ( ) {
        if (mySPI.available()) {
          Serial.print("Value: 0x");
          Serial.println(mySPI.popr(), HEX);
    Logic Analyser output:
    Teensy's Serial output:
    Last edited by KishoreK31; 08-04-2021 at 09:18 AM.

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Montreal, Canada
    Check to make sure the MISO and MOSI pins are not reversed, try swapping them around and testing it again

    On some teensies, the labels are reversed for MISO and MOSI when in slave mode

Posting Permissions

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