nimaltd / spif

W25qxx, N25Qxx and other SPI FLASH driver for stm32 HAL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read "0xFF" or "0x00"

hosseinghaheri opened this issue · comments

Hi,
Thank you for this library.
I add this to my project.
My MCU is STM32F103C8T6 and I use SPI2 for connect to W25Q128.

Code:

uint8_t rBuff[256]="";
#define PAGE(_x) _x* 0x100;
#define SEC(_x)  _x* 0x1000;
#define BLK(_x)  _x* 0x10000;
//----------------------------------------------
StartAddress=SEC(7);

W25qxx_EraseSector(StartAddress);
W25qxx_WritePage("0123456789", StartAddress, 0, 10);

sprintf(rBuff,"");
W25qxx_ReadPage(rBuff, StartAddress,0,10);

But I have a problem, After call "W25qxx_ReadPage" function , the all values of "rBuff" elements is "0xFF" or "0x00" (Null).

Thanks!

Please try on address 0
Your address is wrong. See maximum page address in structure after init

uint8_t rBuff[16];
W25qxx_EraseSector(0) // erase page 0~15;
W25qxx_WritePage("0123456789", 0, 0, 10);
W25qxx_ReadPage(rBuff, 0,0,10);

I tried this

uint8_t rBuff[16];
W25qxx_EraseSector(0) // erase page 0~15;
W25qxx_WritePage("0123456789", 0, 0, 10);
W25qxx_ReadPage(rBuff, 0,0,10);

For the first time everything was right, but after Reset MCU , I got "0xff" again.
Results:

w25qxx EraseSector 0 Begin...
w25qxx EraseSector done after 25 ms
w25qxx WritePage:0, Offset:0 ,Writes 0 Bytes, begin...

w25qxx WritePage done after 14 ms
w25qxx ReadPage:0, Offset:0 ,Read 0 Bytes, begin...

w25qxx ReadPage done after 0 ms

Have You correct report from chip on initialization stage?

I Receive this :

w25qxx Init Begin...
w25qxx ID:0x848480
w25qxx Unknown ID
w25qxx EraseBlock 0 Begin...
w25qxx Init Begin...
w25qxx ID:0xFFFFFF
w25qxx Unknown ID
w25qxx EraseBlock 0 Begin...
w25qxx EraseBlock done after 12 ms
+++w25qxx WriteSector:0, Offset:0 ,Write 0 Bytes, begin...
---w25qxx WriteSector Faild!
+++w25qxx ReadSector:0, Offset:0 ,Read 0 Bytes, begin...
---w25qxx ReadSector Faild!

Circuit:
w25q128

I've faced the same issue with stm32g070x. @hosseinghaheri any updates?

I already have tried with the lowest speed. I can read ID, and it looks like I can erase the chip. But later I always get 0 from Reading. WP and HOLD are high

I set Baud Rate on 9 MBits/s , and the problem was solved.
Sometimes I got "0x00" because of a problem with hardware connections.
Thanks to everyone! 👍

Thanks for your feedback

In my case, there was a kind of bad wiring/soldering. I resoldered the scheme and now it works like a charm

UPD: it was a power issue -_- VCC was very low - 3.1V instead of 3.3
UPD2: use as short wires as possible. 10cm - ok, 20cm - bad

uint8_t rBuff[16];
W25qxx_EraseSector(0) // erase page 0~15;
W25qxx_WritePage("0123456789", 0, 0, 10);
W25qxx_ReadPage(rBuff, 0,0,10);

I tried this, but always getting 0xFF on read. WP and HOLD are pulled to high through 10K resistor.
Here, are output and schematic:
schematic

output_oxff

@namanPuri change your flash chip and try again.