Arduino与Proteus仿真实例-M95256串行(SPI)EEPROM数据存取驱动仿真
M95256串行(SPI)EEPROM数据存取驱动仿真
1、M95256介绍
M95256 器件是组织为 32768 x 8 位的电可擦除可编程存储器 (EEPROM),可通过 SPI 总线访问。
M95256-W 可在 2.5 V 至 5.5 V 的电源电压下工作,M95256-R 可在 1.8 V 至 5.5 V 的电源电压下工作,M95256-DF 可在 1.7 V 至 5.5 V 的电源电压下工作, 在 -40 °C / +85 °C 的环境温度范围内。
M95256-DF、-DR 或-DW(以下简称 M95256-Dx)提供了一个额外的页面,称为标识页面(64 字节)。 标识页面可用于存储敏感的应用程序参数,这些参数可以(稍后)以只读模式永久锁定。

引脚功能如下表所示:

2、仿真电路原理图

3、仿真代码实现
本次实例使用如下开源库:
演示代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| #include <M95M01.h> const uint8\_t CS = 10; int readPin = 2; int writePin = 3; uint8\_t counts = 1; byte readState; byte writeState;
void read\_interrupt(){ readState = 1; }
void write\_interrupt(){ writeState = 1; }
void setup(){ pinMode(readPin,INPUT); pinMode(writePin,INPUT); // 绑定按键中断 attachInterrupt(digitalPinToInterrupt(readPin),read_interrupt,RISING); attachInterrupt(digitalPinToInterrupt(writePin),write_interrupt,RISING); M95M01.begin(CS, 2000000); //初始化并设置SPI的时钟为2MHz Serial.begin(9600);
// Wire.begin(); Serial.println("\*\*\*\*EEPROM M95M256 \*\*\*\*"); }
void loop(){ if(readState){ int value = M95M01.read\_byte(0); // 读数据 Serial.print("read:"); Serial.print(value); Serial.println(); readState = 0; }
if(writeState){ Serial.print("write:"); Serial.print(counts); Serial.println(); M95M01.write\_byte(0, counts); // 写数据 counts++; writeState = 0; } }
|
4、仿真结果

文章来源: https://iotsmart.blog.csdn.net/article/details/121042863
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!