- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let me start by saying I saw this exact problem posted a week ago, and "resolved" by decreasing the clock frequency from 2MHz to 1MHz.
This solution did not work for me. I went as low as 100KHz and the result is always the same.
On to the problem:
I am trying to write a driver for an s70fl01gs chip. I am successfully reading status register, sfdp register, RDID, etc. I am also able to toggle (and verify) the write enable bit in status reg using WREN and WRDI commands. When I read/write/read, however, my read values are always the same. I am not sure if my write op is not going through, or if I am reading incorrectly. Here is my code for read() and write():
bool FLASH_Read(size_t addr, size_t len, uint8_t* data){
int delay = 0x1FFF;
int i;
while(delay-- && (FLASH_RDSR() & 1));
if (!delay)
return false;
FLASH_CS_SELECT();
transferSPI(SPI_READ_CMD);
transferSPI(addr >> 16);
transferSPI(addr >> 8);
transferSPI(addr);
for (i = 0; i < len; i++)
*data++ = transferSPI(0);
FLASH_CS_DESELECT();
return true;
}
bool FLASH_Write(size_t addr, size_t len, uint8_t* data){
int i;
int delay;
delay = 0x1FFF;
while(delay-- && (FLASH_RDSR() & 1));
if (!delay)
return false;
delay = 0x1FFF;
do { FLASH_WREN(); } while(delay-- && !(FLASH_RDSR() & 2));
if (!delay)
return false;
FLASH_CS_SELECT();
transferSPI(SPI_PP_CMD);
transferSPI(addr >> 16);
transferSPI(addr >> 8);
transferSPI(addr);
for (i = 0; i < len; i++)
transferSPI(data);
FLASH_CS_DESELECT();
return true;
}
I captured the signal using a logic analyzer, and took some screenshots of the read op, write op, and read sfdp reg op (which received the expected data correctly). Any help is greatly appreciated!
First here is my successful SFDP read:
Now here is the first read op:
After that, I try to write a different value:
And then I try to read again, and get the same value I read initially..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Read/Write functions are the waveform looks OK. S70FL01GS is a dual die device and it has 2 chip select pins. Could you please double check that you are reading and writing to the same die inside the chip? Can you try to erase the sector before reprogramming new values?
Are you facing this issue with all of the devices that you tested? Or, only a few are showing this behavior?
Thanks and Regards,
Sudheesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Sudheesh,
Thanks for getting back to me. I was getting the same response from both CS1 and CS2. I actually have an FRAM on the same SPI bus, and I verified I was selecting the correct CS every time. Also tried with and without the FRAM, with no luck.
I tested three different chips and they all had the same result. Sector Erase and Bulk Erase didn't help either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Sorry for the delay.
Did you perform erase operation before writing new values? Can you send waveform for below sequence of operations?
- Read data
- WREN command
- Erase sector
- Poll status register to make sure the operation is finished (do not use fixed delay).
- Read data
- WREN command
- Write new data
- Poll status register to make sure the operation is finished (do not use fixed delay).
- Read data
It is not recommended to wait a fixed time after erase and program operations. Please check only status register to know the completion status of program and erase operations.
Can you share your complete source code with us? We can review it and let you know if there are any issues with it.
Thank and Regards,
Sudheesh