spif icon indicating copy to clipboard operation
spif copied to clipboard

Read "0xFF" or "0x00"

Open hosseinghaheri opened this issue 5 years ago • 14 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!

hosseinghaheri avatar Mar 29 '20 23:03 hosseinghaheri

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

nimaltd avatar Mar 30 '20 04:03 nimaltd

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

2020-03-30 4:41 GMT+05:00, Hossein Ghaheri [email protected]:

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

AlexKeisy avatar Mar 30 '20 09:03 AlexKeisy

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

nimaltd avatar Mar 30 '20 09:03 nimaltd

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

hosseinghaheri avatar Mar 30 '20 12:03 hosseinghaheri

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

MikhailNatalenko avatar Mar 31 '20 20:03 MikhailNatalenko

Maybe need to decrease speed?

2020-03-30 17:06 GMT+05:00, Hossein Ghaheri [email protected]:

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

AlexKeisy avatar Apr 01 '20 06:04 AlexKeisy

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

MikhailNatalenko avatar Apr 01 '20 06:04 MikhailNatalenko

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

hosseinghaheri avatar Apr 01 '20 09:04 hosseinghaheri

Thanks for your feedback

nimaltd avatar Apr 01 '20 10:04 nimaltd

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

MikhailNatalenko avatar Apr 01 '20 11:04 MikhailNatalenko

@MikhailNatalenko 👍👍👍

nimaltd avatar Apr 01 '20 11:04 nimaltd

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 [email protected]:

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

AlexKeisy avatar Apr 03 '20 11:04 AlexKeisy

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 avatar Jul 11 '20 06:07 namanPuri

@namanPuri change your flash chip and try again.

nimaltd avatar Jul 11 '20 07:07 nimaltd