LowPowerLab / SPIFlash

Arduino library for read/write access to SPI flash memory chips
GNU General Public License v3.0
173 stars 91 forks source link

Infinite loop when executing command on sleeping device (including wakeup()) #5

Closed m-kozlowski closed 9 years ago

m-kozlowski commented 9 years ago

According to datasheet, powered down chip will ignore every instruction except "Release from Power-Down" and "Device ID". This includes the Read Status Register.

In such scenario (at least on my platform) SPI.transfer(SPIFLASH_STATUSREAD) always returns 0xFF, so while(busy()) loop will never complete. This loop is executed before sending instruction to the chip, so there is no way to access flash after sleeping it.

LowPowerLab commented 9 years ago

Read status register should return 0x0 not anything else so while(busy()) should pass immediately. If you get a non 0 result on MISO it means you have a noise/static issue on the open drain MISO and you should pulldown the MISO line to avoid that. See also this related and basically same issue: https://github.com/LowPowerLab/SPIFlash/issues/4