23K256 SPI interfacing

Test code

#include "mbed.h"

Serial pc(USBTX, USBRX);
SPI spi(PTD2, PTD3, PTD1);
DigitalOut cs(PTC5);

int main() {
    int ret=-1;
    int i=0;

    pc.baud(115200);
    
    printf("begin write\r\n");
    for (i=0; i<0x8000; i++) {
        cs = 0;
        spi.write(0b00000010);
        spi.write((i>>8) & 0xFF);
        spi.write(i & 0xFF);
        spi.write(('a'+i)%'z');
        cs = 1;
    }
    printf("write done\r\n");

    printf("begin read\r\n");
    for (i=3555; i<12000; i++) {
        cs = 0;
        spi.write(0b00000011);
        spi.write((i>>8) & 0xFF);
        spi.write(i & 0xFF);
        ret = spi.write(0xFF);
        printf("ret_rp=%d\r\n", ret);
        cs = 1;
    }

    while (true) {

    }
}

Datasheet

http://ww1.microchip.com/downloads/en/DeviceDoc/22100F.pdf


Please log in to post comments.