No Clock and MISO traffic on SPI lines for ADXL375 using teensy 3.2

I'm trying to get this ADXL375 eval board to communicate with my teensy 3.2 using SPI, by reading out the device ID register from the ADXL. A sigrok pulseview logic analyser shows that the CS pin is succesfully pulled low when it needs to be, and that MOSI data is correctly sent out to the ADXL.

However no clock signal is detected, and no MISO data is recorded. Especially odd is that the built-in LED pin on the teensy board is lighting up. This LED has the same value as pin 13 (the clock line).

I've tested a similar (but slightly different) SPI setup on a ADXL355 and there it worked fine, with the same teensy board.

Would anyone be able to tell what is going wrong?

#include <SPI.h>  // include the SPI library:


#define SPI_DUMMY_VALUE       0b10101010  // value is irrelevant 
#define ADXL375_CS_PIN        9



void setup() {

  pinMode (ADXL375_CS_PIN, OUTPUT); 
  digitalWrite(ADXL375_CS_PIN, HIGH); 

  Serial.begin(9600); 
  
  SPI.begin(); 
}

void loop() {

  delay(100);  
  
  uint8_t outVal = singleByteReadSPI(0x00); // should return the device ID (0xE5) 

  Serial.println(outVal, HEX); 


}

uint8_t singleByteReadSPI(uint8_t address) {    

     SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3)); 

     digitalWrite(ADXL375_CS_PIN,LOW);

    //  send in the first byte. This must contain: R/W bit, MB (multi byte) bit, and address of register to read from
     uint8_t readMBaddr = 0b10000000 | address; //  From left to right: read (1), not multibyte (0), and then a bunch of zeros

    // send the first byte. Output is irrelevant so not recorded. 
    SPI.transfer(readMBaddr);  
    
    //  send the second byte. Dummy byte because a dummy is necessary to shift bits. Input is irrelevant. 
    uint8_t out = SPI.transfer(SPI_DUMMY_VALUE);

    // take the SS pin high to de-select the chip:
     digitalWrite(ADXL375_CS_PIN,HIGH); 

    // end transaction 
    SPI.endTransaction(); 

    return out; 
}




Problem resolved (see pulseview). Turned out the wires and the breadboard were in a bad state, so I immediately threw those wires in the bin. Connections themselves were correct.

The golden tip came from Majenko from Arduino stack exchange. He suggested to 'blink' the lines that were not giving any signal to see if all the wiring was alright.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.