Well I've been stuck on this for a while, maybe 2-3 weeks at this point. I'm just not sure what I'm doing wrong. I'm trying to write to this spi flash part, and now I'm just running routines to erase, write, and read to try to isolate it but so far no luck. Of course I've solved a bunch a bugs along the way...

Anyway I've got my WP line tied high on the board, and I've slowed the clock way down to 200khz, then I run my erase routine and it looks like this:

enter image description here First I check the ID just for debug, that's the 9F command, then I set WREN with 06 command, C7 is the whole chip-erase, and then I check the status bit with 05 and it's clear. This thing's chip erase time is only 35ms.

Now I reload my code and try a write:

enter image description here First I set WREN with 06, check status to see that WREN is set with 05, it is, then send the page program command 02 to address 0x000000. You can see I'm writing deadcafe as the first few bits. Also not pictured here is after the write completes (one page or 256 bytes), I send the 0x04 command to disable WREN. I have observed that and I did set the last four bytes of my page buffer to be 0xAA, 0x55, 0xAA, 0x55 and I saw them just before the CS goes high.

Now stop reload code and try to run a read cycle: enter image description here Send 0x03 as the read command and 0x000000 as the address, and... all 0xFF back from the device.

I can see the device responding to my read ID and set WREN commands so I know it hears me, and can respond. I don't know what I'm doing wrong at this point. I guess I'll go back to reading the datasheet, and trying some things but if anyone has any insight I'd appreciate the help. It's shaping up to be another frustrating weekend working on this thing.

  • 10
    \$\begingroup\$ And... I figured it out. If I had a dollar for every time I figured something out after finally getting desperate enough to post somewhere for help. Turns out there's another command 0x98 called Global Unlock, which is not mentioned in the sections on write enable or programming... Anyway adding that ahead of my WREN command and it worked. sorry for the bother. \$\endgroup\$
    – confused
    Commented Feb 21, 2015 at 23:06
  • 10
    \$\begingroup\$ Add your comment as an answer and accept it. \$\endgroup\$ Commented Feb 22, 2015 at 3:20
  • \$\begingroup\$ Agreeing with @geometrikal that you should answer your own question. I had nothing but trouble with the PIC SPI interface; for the exact same reasons: the documentation. \$\endgroup\$
    – User.1
    Commented Feb 22, 2015 at 11:06
  • 2
    \$\begingroup\$ Hi! You posted a good question about a year ago and then posted a good answer in the comments. But the question is still showing up at the top of the "Unanswered" list! Please copy your comments into an answer and mark it "Accepted". This way it will be managed correctly and we can upvote your answer :) \$\endgroup\$
    – bitsmack
    Commented Feb 18, 2016 at 1:00
  • 1
    \$\begingroup\$ @confused please post your answer and mark it as answered so we can close the question, Thanks \$\endgroup\$
    – Voltage Spike
    Commented Feb 23, 2016 at 17:02

1 Answer 1


I just hate that this is still at the top of the 'unanswered' list, so I'm going to answer.

As stated in the comments by 'confused', there is a command called 'Global Unlock' that must be executed before writing to the flash part.

  • 1
    \$\begingroup\$ You should accept your answer, otherwise this question will still be marked as "unanswered". \$\endgroup\$
    – Étienne
    Commented Mar 30, 2016 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.