Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Hi, I have a problem interfacing the SST25VF016B serial flash from Microchip.
Here is my code:
#include "mbed.h" DigitalOut sr(p21); SPI spi(p5,p6,p7); int main() { wait(0.2); spi.format(8,0); spi.frequency(10000000); // read JEDEC-ID sr=0; spi.write(0x9F); // read JEDEC ID printf("%x\n", spi.write(0)); printf("%x\n", spi.write(0)); printf("%x\n", spi.write(0)); sr=1; // send WREN command sr=0; spi.write(0x06); //WREN sr=1; // write first byte sr=0; spi.write(0x02); // write spi.write(0);// // 3 bytes for address, msb first spi.write(0); spi.write(0); spi.write('u'); sr=1; // write second byte sr=0; spi.write(0x02); spi.write(0); spi.write(0); spi.write(1); spi.write('t'); sr=1; // write third byte (string end marker) sr=0; spi.write(0x02); spi.write(0); spi.write(0); spi.write(2); spi.write(0); sr=1; // read first byte sr=0; spi.write(0x03); // read command spi.write(0); // 3 byte address spi.write(0); spi.write(0); printf("%c\n", spi.write(0)); sr=1; // read second byte sr=0; spi.write(0x03); spi.write(0); spi.write(0); spi.write(1); printf("%c\n", spi.write(0)); sr=1; }The JEDEC ID will be read correctly (bf 25 41), but the other 2 bytes were not written nor read.
Do I have to do additional things before writing?
Here ist the datasheet: /media/uploads/emmibed/sst25vf016b_serialflash_spi.pdf