Getting capacity of SPIFlash

Started by sketchy, December 17, 2013, 12:57:24 PM

sketchy

p. 15 of http://www.winbond.com/NR/rdonlyres/6E25084C-0BFE-4B25-903D-AE10221A0929/0/W25X40CL.pdf)

Notes the JEDIC ID is three bytes, with the LSB being capacity (which I assume should be 4Mbits based on what I was shipped).

The function in SPIFlash.cpp readDeviceID() returns a word - i.e.: the first two bytes (0XEF30).

--> Shouldn't it return 3 bytes? (0xEF3013 in the case of the W25X40CL)
--> If the third byte is capacity, and the capacity is 4Mbits, what does 13h (19d) relate to 4Mbits (what am I missing on reading this byte and interpreting capacity?)

My interest in this is to write sensor info up to the end of capacity, then start over again.  My thought was to get the capacity to know how many bytes I can store.  I hoped to do this in the sketch so that if another SPIFlash chip is used with a different capacity, the sketch would not have to be touched).

Thank you.

Felix

You are correct, there are 3 bytes. Since I had the word datatype to work with and I wanted a way to identify the FLASH I'm working with, I just wanted 2 bytes. You can certainly make that a LONG and read 3 bytes and a 0, or just read the extra array size byte. I might add this in the lib some time...