-
Notifications
You must be signed in to change notification settings - Fork 14
Description
I'm using a Teensy 3.1 and a AT45DB161D. For some reason, the very first status code read from the chip always returns 0. This causes the dataflash library to misinitialize its member variables and subsequently, most functions don't work as expected. I've narrowed it down to the SPI mode: with SPI mode 0, it works. With SPI mode 3, the first status code is 0 and subsequent status codes are good.
Therefore two suggestions for dataflash:
- maybe change to SPI mode 0
- prevent buffer overrun in Dataflash::setup() due to deviceIndex out-of-range (e.g. choose a default chip type)
Below is a small example program to reproduce (only shows the first status code):
include <SPI.h>
define MY_SCS 10
uint8_t st;
void setup() {
Serial.begin(9600);
// initialize SPI
pinMode(MY_SCS, OUTPUT);
digitalWrite(MY_SCS, HIGH);
SPI.begin();
SPI.setDataMode(SPI_MODE3); // NO
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV2);
// enable chip
digitalWrite(MY_SCS, LOW);
// status
SPI.transfer(0xd7);
st = SPI.transfer(0);
// disable chip
digitalWrite(MY_SCS, HIGH);
}
void loop() {
Serial.println(st, HEX);
delay(1000);
}