Hi guys,
I'm trying to read some MEMS sensors over SPI using Arduino Due. If I declare the SS pin inside SPI.begin(), I get quite the expected behavior, though sometime it returns me 0xFF. Instead, if I use digitalWrite(), all I get is 0xFF regardless of the ClockDivider or the DataMode. It seems to be related to the SS pin not going low properly.
I currently do not have the possibility to use an oscilloscope.
Do you have any suggestion, like using some pull-ups/pull-downs?
This way it is impossible for me to have a reliable connection. It is simply not working the way it should. The sensor I'm testing is a LPS25HB from ST.
Thanks to everyone
#include <SPI.h>
void setup() {
SPI.begin(52);
Serial.begin(115200);
Serial.setTimeout(200);
SPI.setClockDivider(52,200);
SPI.setBitOrder(52,MSBFIRST);
SPI.setDataMode(52,SPI_MODE0);
Serial.println("Starting...");
delay(500);
SPI.transfer(52,0x0F|0x80, SPI_CONTINUE);
uint8_t asd=SPI.transfer(52,0x00);
Serial.println(asd, BIN);
delay(500);
}
#include <SPI.h>
void setup() {
pinMode(52,OUTPUT);
pinMode(52,HIGH);
SPI.begin();
Serial.begin(115200);
Serial.setTimeout(200);
SPI.setClockDivider(200);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
Serial.println("Starting...");
delay(500);
digitalWrite(52,LOW);
SPI.transfer(0x0F|0x80, SPI_CONTINUE);
uint8_t asd=SPI.transfer(0x00);
digitalWrite(52,HIGH);
Serial.println(asd, BIN);
delay(500);
}
