Author Topic: Flash init fails - no response to 0x9F SPIFLASH_IDREAD  (Read 1494 times)

frankleonrose

  • NewMember
  • *
  • Posts: 4
Flash init fails - no response to 0x9F SPIFLASH_IDREAD
« on: July 30, 2018, 10:10:57 AM »
I'm using the LPL https://github.com/lowpowerlab/spiflash library and a MoteinoM0. Flash is declared thus:

SPIFlash flash(SS_FLASHMEM, 0xEF30); //EF30 for 4mbit  Windbond chip (W25X40CL)

and then flash.initialize() returns false.

Looking at it with a logic analyzer, I see chip select operating correctly. 0xAB (wakeup/reset) gets sent and flash chip puts 0x00 on MISO. The library waits for 10µs (sufficient for wakeup per chip spec) and then puts 0x9F to read the chip ID. Two problems:

1. When 0x9F is clocked out, the flash chip puts out 0x1F or 0x9F on MISO. It's ok, it's ignored. But unexpected.
2. When the 0x00 0x00 is clocked out, the flash chip fails to write an ID - the MISO line just stays low yielding 0x00 0x00 response.

Has anyone seen this behavior?

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Flash init fails - no response to 0x9F SPIFLASH_IDREAD
« Reply #1 on: July 30, 2018, 11:45:18 AM »
I haven't, it should work, part of testing is the FLASHMEM chip passing initialize and doing a read.

Is this with a bare MoteinoM0 or anything else attached to it/SPI?

frankleonrose

  • NewMember
  • *
  • Posts: 4
Re: Flash init fails - no response to 0x9F SPIFLASH_IDREAD
« Reply #2 on: July 30, 2018, 02:50:04 PM »
Doh! It just occurred to me and I've made this mistake before. (And I hadn't seen your response, @felix, which I hope would have made me realize).

Before doing anything, set all chip select lines to OUTPUT/HIGH!

I am initializing the Flash first, before any calls to my LoRa code. But if the LoRa SS line is floating or low, the Semtech 1276 is going to start chatting on those lines when I'm trying to talk to the Flash.

Is there a reason you didn't need to do that in the example deep sleep sketch, @felix?

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Flash init fails - no response to 0x9F SPIFLASH_IDREAD
« Reply #3 on: July 31, 2018, 01:02:22 PM »
Yes all SPI CS-es should be HIGH.

Is there a reason you didn't need to do that in the example deep sleep sketch, @felix?

Because SPIFlash does it for you.