W25Q64 Memory Module
Module Source
Specifications
It has been tested and can be connected to a 5V power supply.
Hardware Interface
- Connect the W25Q64's Vcc pin to 5V on the development board.
- Connect the W25Q64's GND pin to the development board's GND.
- connect the CS (chip select) pin of the W25Q64 to a digital pin (e.g., pin 10) on the development board.
- Connect the W25Q64's CLK (clock) pin to pin 13 (SCK) of the development board.
- Connect the W25Q64's DI (Data Input) pin to pin 11 (MOSI) of the development board.
- Connect the DO (data output) pin of the W25Q64 to pin 12 (MISO) of the development board.
Usage Method
Install Library
- Open “Tools” > “Manage Libraries” in Arduino IDE, search for “SPIMemory” and install this library.
Enter the code:
c
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 18, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <SPI.h>
#include <SPIMemory.h>
#define FLASH_CS 10 // W25Q64的CS连接到Arduino的10号引脚
SPIFlash flash(FLASH_CS);
void setup() {
Serial.begin(9600);
if (!flash.begin()) {
Serial.println("初始化Flash失败!");
return;
}
Serial.println("Flash初始化成功!");
uint32_t jedecID = flash.getJEDECID();
Serial.print("JEDEC ID: ");
Serial.println(jedecID, HEX);
// 写入数据到地址0的位置
flash.writeByte(0, 0xA5);
// 读取地址0的数据
uint8_t readData = flash.readByte(0);
Serial.print("读取到的数据: ");
Serial.println(readData, HEX);
}
void loop() {
// 不需要重复执行的代码
}
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
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