KAmod SPI Flash
From Kamamilabs.com - Wiki

Description
KAmod SPI Flash - Non-Volatile Flash Memory Module with SPI Interface
The KAmod SPI Flash module contains Flash memory with an SPI interface. All control signals are routed as through-hole pads, arranged with a standard 2.54 mm pitch, close to the board edge and in a DIL8 through-hole package. The module is available with 1 MB (8 MB) or 16 MB (128 MB) memory capacities.

Basic Features and Parameters
- Non-volatile Flash memory with a capacity of 1 MB (W25Q80) or 16 MB (W25Q128)
- SPI interface clocked at up to 50 MHz (operation at higher frequencies is possible, but depends on the quality/length of the SPI signal connections)
- Memory contents can be protected from erasure by installing the "Write protect" jumper
- Control signals are connected as solder pads with holes, arranged with a standard 2.54 mm pitch, right at the edge of the board
- Control signals are also connected as solder pads with holes, arranged with a standard 2.54 mm pitch, corresponding to a DIL8 through-hole package
- Power supply voltage: 2.7...3.6 V
- Board dimensions: 27 x 18.3 mm
Standard Equipment
| Code | Description |
|---|---|
| KAmod SPI Flash |
|

Schemat elektryczny

Control Signals
| Marking (J1) | Function |
|---|---|
| CS |
|
| SCK |
|
| DI |
|
| DO |
|
| GND |
|
| V+ |
|
| WP |
|
| HOLD |
|
Communication with the W25Q80/W25Q128 memories used in the KAmod SPI Flash is possible via the SPI interface. Some signals perform dual functions in Dual/Quad SPI communication modes. A detailed description of all signals, communication methods, procedures, and commands is included in the technical documentation for the devices.
The SPI interface of W25Qxxx memory devices can operate at very high clock speeds (signal at the SCK input) – even over 100 MHz. However, for a wired module, communication at clock speeds higher than 50 MHz is not recommended. If communication problems occur, reduce the SPI clock frequency.
The layout of the control signals is shown in the figures below. The signal markings are located on the bottom of the board, both for the edge connector and for the DIL8 package.
Memory Capacity Designation
The KAmod SPI Flash module is available with 1 MB (8 MB) or 16 MB (128 MB) memory capacities. Depending on the version, the board uses either the W25Q80 (1 MB) or W25Q128 (16 MB) chips.
The memory version is marked on the bottom of the board, as shown below.
Write protection "Write protect"
| Marking (J1) | Function |
|---|---|
| WP (J1) |
|
| Write protect |
|
The Write Protect function protects the memory from being erased or its contents changed.
To activate the protection function, apply a low state (logical 0) to the WP pin. Another method is to solder a drop of solder in place of the SMD jumper or solder the goldpins with the jumper mounted, as shown in the figure. Installing a jumper also forces a low state on the WP pin.

Power
| Designation | Function |
|---|---|
|
|
The KAmod SPI Flash module can be powered by a DC voltage of 2.7...3.6V, connected to the V+ and GND pins on the J1 connector.
|
Do not connect 5V power supply! |

Dimensions
The KAmod SPI Flash board dimensions are 27x18.3 mm. There are two mounting holes on the board, each with a diameter of 3.2 mm.

Test Program
The test program was written in the Arduino environment for the KAmodESP32 POW RS485 board.
//example code for KAmod SPI Flash 1MB (W25Q80)
//ino board: ESP32-WROOM-DA Module
#include <SPI.h>
#include "Kamod_SPIFlashBase.h"
//LED
#define LED_PIN 2
#define MY_DELAY 2000
//SPI
#define SPI_MOSI 13
#define SPI_MISO 12
#define SPI_SCK 14
#define SPI_CS 15
#define SPI_CLOCK 10000000
//INIT
SPIClass spiFlashBus(HSPI);
Kamod_SPIFlashBase spiFlashBase(&spiFlashBus, SPI_CS, SPI_SCK, SPI_MOSI, SPI_MISO);
Kamod_SPIFlash_Device_t MY_W25Q80DV;
uint8_t *data_buff;
int ledi;
int loops;
bool retstat;
bool verify;
int result;
//-------------------------------------------
void setup() {
Serial.begin(115200);
while (!Serial) {}
delay(1000); // wait for native usb
Serial.println();
Serial.println();
Serial.println();
Serial.println("Hello. KAmod SPI Flash test start");
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
ledi = 0;
retstat = false;
while(retstat == false){
spiFlashBus.begin(SPI_SCK, SPI_MISO, SPI_MOSI, SPI_CS);
spiFlashBase.setClockSpeed(SPI_CLOCK, SPI_CLOCK);
retstat = spiFlashBase.begin(&MY_W25Q80DV);
if (!retstat){
Serial.println("Init fail ");
delay(1000);
} else {
Serial.print("JEDEC: ");
Serial.println(spiFlashBase.getJEDECID(), HEX);
}
}
Serial.println("Flash init...OK");
Serial.println("--- First, erase sector ---");
spiFlashBase.eraseSector(0);
delay(500);
loops = 0;
result = 0;
Serial.println();
}
//-------------------------------------------
void loop() {
Serial.print("### START at page: ");
Serial.print(loops);
Serial.println(" ###");
Serial.println("--- Clear buff ---");
data_buff = spiFlashBase.buff();
for(int n = 0; n<KAMOD_SFLASH80_PAGE_SIZE; n++){
*data_buff = 0;
data_buff++;
}
Serial.println("--- Read mem ---");
spiFlashBase.readPageBuff(loops * KAMOD_SFLASH80_PAGE_SIZE);
data_buff = spiFlashBase.buff();
for(int n = 0; n<20; n++){
Serial.print(*data_buff);
Serial.print(",");
data_buff++;
}
Serial.println("");
Serial.println("--- Prepare new buff ---");
data_buff = spiFlashBase.buff();
for(int n = 0; n<20; n++){
*data_buff = (uint8_t)(n + (loops*10));
Serial.print(*data_buff);
Serial.print(",");
data_buff++;
}
Serial.println("");
Serial.println("--- Write mem ---");
//spiFlashBase.eraseSector(0);
spiFlashBase.writePageBuff(loops * KAMOD_SFLASH80_PAGE_SIZE);
Serial.println("--- Clear buff ---");
data_buff = spiFlashBase.buff();
for(int n = 0; n<KAMOD_SFLASH80_PAGE_SIZE; n++){
*data_buff = 0;
data_buff++;
}
Serial.println("--- Read mem for check content ---");
spiFlashBase.readPageBuff(loops * KAMOD_SFLASH80_PAGE_SIZE);
data_buff = spiFlashBase.buff();
for(int n = 0; n<20; n++){
Serial.print(*data_buff);
Serial.print(",");
data_buff++;
}
Serial.println("");
Serial.print("### Verify ");
verify = true;
data_buff = spiFlashBase.buff();
for(int n = 0; n<20; n++){
if (*data_buff != (uint8_t)(n + (loops*10))) verify = false;
data_buff++;
}
if (verify) {
result++;
Serial.println("OK ###");
}
else Serial.println("FAIL !!! ###");
ledi++;
digitalWrite(LED_PIN, (ledi&1));
Serial.println();
Serial.println();
Serial.println();
delay(500);
loops++;
if (loops >= 3) {
if (result == 3) Serial.println("### Verify OK 3 times ###");
else Serial.println("!!! Some things are wrong, some verifications fail !!!!");
Serial.println("### THATS ALL ###");
while(1){};
}
}