关键字:RTC,定时器, Flash, stm32,SPI,
W25Q16
25Q系列,**16M-bit(1bytes=8 bits) **的flash。可以保存voice,text,data.
The W25Q16JV array is organized into 8,192 programmable pages of 256-bytes each. Up to 256 bytes can be programmed at a time. Pages canbe erased in groups of 16 (4KB sector erase), groups of 128 (32KB block erase), groups of 256 (64KB block erase) or the entire chip (chip erase).
每一页有256个字节,有8192页。 2M-bytes。
2M=32*64K;一片flash分为32块(block),每个block是64kb,一个扇区为4k。也就是说一个block有16个扇区。
写: 可写1-256个字节,支持一个字节,一个字节的单独写。一次可写256个字节。
擦除: 只能扇区或者块擦除。 16个256字节 (4k)为一个扇区擦除。128个256字节(32k)为一块擦除。256个256字节(64k)擦除。整块芯片擦除。
芯片内执行(XIP,eXecute In Place)XIP
- standSPI:上升沿,DI写指令,地址,数据。下降沿,DO读数据,状态。
- dualSPI:根据指令。
- quad SPI:根据指令。
1. 指令操作
the falling edge 下降沿,写指令操作。
the rising edge 上升沿,写数据操作。
1.1 sector Erase(20h)扇区擦除
擦除是指将所有数据都置1。
- write enable instruciton.
- Driving the /CS pin low.
- shifting the instruciton code 20h followed a 24-bit sector address(A23-A0).
- Driving the /CS high.
在擦除期间需要读的时候,必须先确认BUSY bit。当BUSY bit=1 说明还在读。当BUSY bit=0说明读完了。
1.2 Write Enable (06h) 写使能
设置WEL(Write Enable latch)bit 为1。在
Page Program,Quad Page Program,Secotr Erase,Block EraseChip Erase,Write Status Register Erase/Program之前。
- Driving the /CS low
- shift the instruction code 06h
- Driving the /CS high
写完之后,通过读取Read status Register instrcution 指令 判断是是否写完。
2 Page Program(02h) 写数据
- Write enable
- Driving the /CS low.
- shift the instrcution code 02h
- shift a 14-bit address (A23-A0)
如果一页写的数据超过了256个字节将会擦除当页已经写过的数据。
If more than 256 bytes are sent to the device the addressing will wrap to the beginning of the page
and overwrite previously sent data.
总结
内部封装一系列指令,SPI与单片机利用SPI通信,根据指令,配合时钟进行读取操作。