Shivanand Gowda
/
SPI_EEPROM
SPI EEPROM Nucleo F767ZI 25LC1024 Serial Read Write Erase
Diff: main.cpp
- Revision:
- 0:f9b337f472e3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 01 12:57:29 2018 +0000 @@ -0,0 +1,78 @@ + +// SPI Single IO NOR eeprom Library for Nucleo F767ZI Interfacing + + + +#include "mbed.h" +#include "EE25LC1024.h" +#include <string> + +Serial pc(USBTX, USBRX); // tx, rx +DigitalOut WP(D7); +int main() +{ + + char str2[24] = {0}; + char str3[24] = {0}; + char str4[24] = {0}; + + + WP=1; + EE25LC1024 eeprom(PA_7, PA_6, PA_5, PA_4); + pc.printf("SPI init done\r\n\r\n"); + + // Read Identification information Related to chip. + + int ID = eeprom.ReleaseDPD_ReadSign(); + printf("ID and Signature is :%d",ID); + + wait(1); + // Reading eeprom Memory Status Register contents. + + + + eeprom.readStream(0x00, str2, 23); + pc.printf("After Read 1 String Here: %s\r\n",str2); + eeprom.readStream(23, str4, 23); + pc.printf("After Read 2 String Here: %s\r\n",str2); + eeprom.readStream(46, str3, 23); + pc.printf("After Read 3 String Here: %s\r\n",str2); + +// write a stream of characters to arbitrary address 0x168 + char stri[] = "Shivanand Gowda Ramaiah"; + + pc.printf("Writing String Here: %s\r\n",stri); + eeprom.writeStream(0x00, stri, 23); //Writing Strings in three Differnt addresses. + eeprom.writeStream(23, stri, 23); + eeprom.writeStream(46, stri, 23); + +// +// uint8_t a=eeprom.readRegister(); +// read stream from 0x168 + + pc.printf("Before String Here: %s\r\n",str2); + eeprom.readStream(0x00, str2, 23); + pc.printf("After Read 1 String Here: %s\r\n",str2); + eeprom.readStream(23, str4, 23); + pc.printf("After Read 2 String Here: %s\r\n",str2); + eeprom.readStream(46, str3, 23); + pc.printf("After Read 3 String Here: %s\r\n",str2); +// +// for(int i=0; i<20;i++) +// pc.printf("Printing byte by byte %c\r\n",str2[i]); + + + // eeprom.sectorErase(0x00); +// while(1) { +// uint8_t busy=eeprom.checkIfBusy(); +// if(busy==0) { +// pc.printf("Not Busy any More \r\n"); +// break; +// } else if (busy==1) +// pc.printf("Busy Now \r\n"); +// } + + pc.printf("Exited from program \r\n"); + return 0; + +}