nimaltd / spif

W25qxx, N25Qxx and other SPI FLASH driver for stm32 HAL
GNU General Public License v3.0
605 stars 173 forks source link

Read "0xFF" or "0x00" #9

Open hosseinghaheri opened 4 years ago

hosseinghaheri commented 4 years ago

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!

nimaltd commented 4 years ago

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

AlexKeisy commented 4 years ago

Have You correct report from chip on initialization stage? like this:

2020-03-30 4:41 GMT+05:00, Hossein Ghaheri notifications@github.com:

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!

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/nimaltd/w25qxx/issues/9

nimaltd commented 4 years ago

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

hosseinghaheri commented 4 years ago

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

MikhailNatalenko commented 4 years ago

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

AlexKeisy commented 4 years ago

Maybe need to decrease speed?

2020-03-30 17:06 GMT+05:00, Hossein Ghaheri notifications@github.com:

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

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/nimaltd/w25qxx/issues/9#issuecomment-605959786

MikhailNatalenko commented 4 years ago

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

hosseinghaheri commented 4 years ago

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! 👍

nimaltd commented 4 years ago

Thanks for your feedback

MikhailNatalenko commented 4 years ago

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

nimaltd commented 4 years ago

@MikhailNatalenko 👍👍👍

AlexKeisy commented 4 years ago

Good day! I think about and...: Why You use diodes d1,d2,d3? I think problem is here. For example when mcu does low W_MOSI pin, cureent flows over diod(its not good because diode take 0.7-0.9V, but ok) and MCUs transistor, when MCU does W_MOSI HIGH, diod d2 is closed, and current flows via R7, and W25Q128`s DI pin input capaticance charged only via R7. Because amount of the resistor is very big You have low speed, and unstable results.

2020-03-30 17:06 GMT+05:00, Hossein Ghaheri notifications@github.com:

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

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/nimaltd/w25qxx/issues/9#issuecomment-605959786

namanPuri commented 4 years ago

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

nimaltd commented 4 years ago

@namanPuri change your flash chip and try again.