Go Down

Topic: SPIMemory library - Formerly SPIFlash - now supports SPI FRAM as well! :) (Read 91852 times) previous topic - next topic

poppy381



My mistake : I thought the TX was working in one side and RX in the other one...

According to this picture, TX is bi directionnal, RX is only one side.

So the DO output from W25q goes to one of these TXI, then TX0 goes to MISO arduino (pin 12 on UNO, pin 50 for Mega)

poppy381

Hello, i've written a function to update a Byte for my needs (and i suppose a lot of people).

Here are the different steps :

1 - Find the sector of the address.
IF Sector < 16
    1 - Erase Sector 16 (my temp sector)
    2 - Copy the Sector target to Sector Temp
    3 - Erase Sector Target
    4 - Update Value address of the buffer Sector Temp
    5 - Copy buffer Sector Temp to Sector target
    6 - End

Note : The readbyteArray/writebytearray is done with a buffer[256] in a loop of 16 iterrations.
A buffer of [4096] doesn't work because you don't have enough memory.

The time measure is 300mS which is not good but not worst.
Feel free to try it and improve it.

Code: [Select]


void updateByte(uint32_t address, byte value) {

const int sizeOfBuffer = 256;
const int sectorSize = 4096;
const int numberTotalOfBytes = 65536;
const int numberOfSectors = 16;
const byte numberOfLoops = 4096 / 256;
const uint32_t address_temp = 65536 - 4096;

byte buffer[sizeOfBuffer];
uint32_t address_sector;
byte sectorNumber;

for (byte i = 0; i < numberOfSectors; i++) {
if ((address > sectorSize* i) && (address < sectorSize * (i + 1))) {
address_sector = sectorSize * i;
sectorNumber = i + 1;
break;
}
}

if (sectorNumber < 16) {

long start2 = millis();
flash.eraseSector(address_temp); 

for (byte i = 0; i < numberOfLoops; i++) {
flash.readByteArray(address_sector + (sizeOfBuffer * i), buffer, sizeOfBuffer);
flash.writeByteArray(address_temp + (sizeOfBuffer * i), buffer, sizeOfBuffer);
}

flash.eraseSector(address);

for (byte i = 0; i < numberOfLoops; i++) {

flash.readByteArray(address_temp + (sizeOfBuffer * i), buffer, sizeOfBuffer);
byte BoucleDeLaValeur = 0;

if ((address > sizeOfBuffer* i) && (address < sizeOfBuffer * (i + 1))) {
BoucleDeLaValeur = i;
buffer[address - (sizeOfBuffer * i)] = value;
}

flash.writeByteArray(address_sector + (sizeOfBuffer * i), buffer, sizeOfBuffer);
}
long FinalTime2 = millis() - start2;
Serial.print(F("Time :")); Serial.println(FinalTime2);
                byte result= flash.readByte(address);
Serial.print(F("Result : ")); Serial.println(result);

}

}

poppy381

According to my code

1 Erase_sector_temp takes around 100mS.
2 Copy data to sector_temp takes around 45mS.
3 Erase_sector Targeted takes around 100mS.
4 Copy data to sector_temp takes around 45mS.

Total around 290mS
This is terribly bad. :'(.



The good new is that it will take pretty much the same time with any arrays to write.

How do you guys deal with that ? If you have an SPI display, you have to shutdown it 300ms will storing...it seems very long.

Do you have good results with Fast Read /dual Read or Quad read ?


Is there a memory chip that can store a lot of data (16MBytes) and be fast when updating a simple byte...

I've read things about FRAM but they are tiny for my needs (256kb)... and expensive.



jacky4566

poppy381 SPI flash is never going to be fast if you are doing any erasing. Its not really intended for rapid erase then write. Most applications are as program ROM (storing variables, bitmaps, etc) or for data logging.

What is your full application? You mention displays so you need a fast read/write buffer then use a RAM chip and store your bitmaps in a flash chip.

poppy381

Hello Jacky and thank you for the answer.

I use and Arduino Mega2560 for this project.

The main problem is that you I to erase Sector before update any byte of a Flash so this is bad for direct access...


My application : Store, read datas as quick as possible because there is a SPI display (dot matrix) with shift registers 74hc595.


User case i'd like :

1 - The user push a button :
     A - SPI : Read Flash to collect strings and different values stored in flash
     B - SPI : Display strings and values (leds)

2 The user change a string name push a button to store :
     A - SPI :The values are stored to Flash


Maybe the SPI protocol should be "parrallal" or very quick to not "see" the display turned off...

You're maybe right I maybe miss a SRAM IC to load the Flash but I need around 4MB. Any advise could be really appreciate :).

I ve found this 2 guy Static RAM 23LC1024:
https://fr.rs-online.com/web/p/products/7697342P/

It works with SPI. How is it supposed to work ?

Your flash is like a hard drive. You copy the datas you need in quick access to your SRAM, said at startup.
If you update a value you can update directly on the RAM.But it's not stored in your Flash so you need to update the flash at the same time.

I'm trying too think that I need two SPI port to not turn off the display.


Regards




FlashPT

Hello,

 I would like to now if its is possible to store a picture.raw in W25Q64 chip and play it with arduino Due.
The objective is to use this chip instead of SD card.

Help please.

Thanks.

Fernando

FlashPT

Hello,

Please someome help ;) !

I need to load one *.RAW or *.C picture 2Mb to 7" tft.

I'm using arduino DUE and SD Card and it's working OK!.

How can I do the same with W25Q128 flash memory?

Thanks for all.

Fernando

ikrajinovic

Hi,

I'm using SST26VF032 with MEGA and Level shifter TXS0108. The problem is I can only write "BYTE" and "CHAR".

Does anyone know what could be the problem in my case?


Code: [Select]

SPIMemory Library version: < 2.5.0

JEDEC ID: 0xBF258D
Man ID: 0xBF
Memory ID: 0x25
Capacity: 4194304
Max Pages: 16384
Unique ID: 04294967040, 0xFFFFFFFFFFFFFF00
-----------------------------------------------------------------------------------------------------------------------------
Testing library code
-----------------------------------------------------------------------------------------------------------------------------
Function Test result      Runtime
-----------------------------------------------------------------------------------------------------------------------------
Power Down    FAIL Not all chips support power down. Check your datasheet.
Power Up    PASS       0 us

Erase Chip    PASS       0 us
Erase 72KB    PASS       0 us
Erase 64KB    PASS       0 us
Erase 32KB    PASS       0 us
Erase 4KB    PASS       0 us
-----------------------------------------------------------------------------------------------------------------------------
Data type I/O Result       Write time       Read time
-----------------------------------------------------------------------------------------------------------------------------
Byte    PASS       0 us
Char    PASS       0 us
Word    FAIL       0 us
Short    FAIL       0 us
ULong    FAIL       0 us
Long    FAIL       0 us
Float    FAIL       0 us
Struct    FAIL       0 us
Byte Array    FAIL 0,    FAIL 1,    FAIL 2,    FAIL 3,    FAIL 4,    FAIL 5,    FAIL 6,    FAIL 7,    FAIL 8,    FAIL 9,    FAIL 10,    FAIL 11,    FAIL 12,    FAIL 13,    FAIL 14,    FAIL 15,    FAIL 16,    FAIL 17,    FAIL 18,    FAIL 19,    FAIL 20,    FAIL 21,    FAIL 22,    FAIL 23,    FAIL 24,    FAIL 25,    FAIL 26,    FAIL 27,    FAIL 28,    FAIL 29,    FAIL 30,    FAIL 31,    FAIL 32,    FAIL 33,    FAIL 34,    FAIL 35,    FAIL 36,    FAIL 37,    FAIL 38,    FAIL 39,    FAIL 40,    FAIL 41,    FAIL 42,    FAIL 43,    FAIL 44,    FAIL 45,    FAIL 46,    FAIL 47,    FAIL 48,    FAIL 49,    FAIL 50,    FAIL 51,    FAIL 52,    FAIL 53,    FAIL 54,    FAIL 55,    FAIL 56,    FAIL 57,    FAIL 58,    FAIL 59,    FAIL 60,    FAIL 61,    FAIL 62,    FAIL 63,    FAIL 64,    FAIL 65,    FAIL 66,    FAIL 67,    FAIL 68,    FAIL 69,    FAIL 70,    FAIL 71,    FAIL 72,    FAIL 73,    FAIL 74,    FAIL 75,    FAIL 76,    FAIL 77,    FAIL 78,    FAIL 79,    FAIL 80,    FAIL 81,    FAIL 82,    FAIL 83,    FAIL 84,    FAIL 85,    FAIL 86,    FAIL 87,    FAIL 88,    FAIL 89,    FAIL 90,    FAIL 91,    FAIL 92,    FAIL 93,    FAIL 94,    FAIL 95,    FAIL 96,    FAIL 97,    FAIL 98,    FAIL 99,    FAIL 100,    FAIL 101,    FAIL 102,    FAIL 103,    FAIL 104,    FAIL 105,    FAIL 106,    FAIL 107,    FAIL 108,    FAIL 109,    FAIL 110,    FAIL 111,    FAIL 112,    FAIL 113,    FAIL 114,    FAIL 115,    FAIL 116,    FAIL 117,    FAIL 118,    FAIL 119,    FAIL 120,    FAIL 121,    FAIL 122,    FAIL 123,    FAIL 124,    FAIL 125,    FAIL 126,    FAIL 127,    FAIL 128,    FAIL 129,    FAIL 130,    FAIL 131,    FAIL 132,    FAIL 133,    FAIL 134,    FAIL 135,    FAIL 136,    FAIL 137,    FAIL 138,    FAIL 139,    FAIL 140,    FAIL 141,    FAIL 142,    FAIL 143,    FAIL 144,    FAIL 145,    FAIL 146,    FAIL 147,    FAIL 148,    FAIL 149,    FAIL 150,    FAIL 151,    FAIL 152,    FAIL 153,    FAIL 154,    FAIL 155,    FAIL 156,    FAIL 157,    FAIL 158,    FAIL 159,    FAIL 160,    FAIL 161,    FAIL 162,    FAIL 163,    FAIL 164,    FAIL 165,    FAIL 166,    FAIL 167,    FAIL 168,    FAIL 169,    FAIL 170,    FAIL 171,    FAIL 172,    FAIL 173,    FAIL 174,    FAIL 175,    FAIL 176,    FAIL 177,    FAIL 178,    FAIL 179,    FAIL 180,    FAIL 181,    FAIL 182,    FAIL 183,    FAIL 184,    FAIL 185,    FAIL 186,    FAIL 187,    FAIL 188,    FAIL 189,    FAIL 190,    FAIL 191,    FAIL 192,    FAIL 193,    FAIL 194,    FAIL 195,    FAIL 196,    FAIL 197,    FAIL 198,    FAIL 199,    FAIL 200,    FAIL 201,    FAIL 202,    FAIL 203,    FAIL 204,    FAIL 205,    FAIL 206,    FAIL 207,    FAIL 208,    FAIL 209,    FAIL 210,    FAIL 211,    FAIL 212,    FAIL 213,    FAIL 214,    FAIL 215,    FAIL 216,    FAIL 217,    FAIL 218,    FAIL 219,    FAIL 220,    FAIL 221,    FAIL 222,    FAIL 223,    FAIL 224,    FAIL 225,    FAIL 226,    FAIL 227,    FAIL 228,    FAIL 229,    FAIL 230,    FAIL 231,    FAIL 232,    FAIL 233,    FAIL 234,    FAIL 235,    FAIL 236,    FAIL 237,    FAIL 238,    FAIL 239,    FAIL 240,    FAIL 241,    FAIL 242,    FAIL 243,    FAIL 244,    FAIL 245,    FAIL 246,    FAIL 247,    FAIL 248,    FAIL 249,    FAIL 250,    FAIL 251,    FAIL 252,    FAIL 253,    FAIL 254,    PASS       0 us

ainghilleri

Hello Marzogh,
first of all, thank you very much for the wonderful work you have done with this library, I have already used it successfully with Mega 2560 chip and W25Q256 memory.

Now I should also use the W25Q256 memory with a new Teensy 4 card that is compatible with the Arduino environment but is not officially supported by your library.

https://www.pjrc.com/store/teensy40.html
(ARM Cortex-M7 processor)

Do you think it's possible? I tried to recompile for this card but got several errors ...
Thanks in advance...

:)

Go Up