Hadi.Dastour
Junior Member level 2
Hi
I have a problem in writing on SST25VF016B flash. I drive it with PIC16LF1516 by using a Software SPI.
My problem is that when I erasea a sector(4KB) of it I can not write any things on that sector any more.
And when I remove erasing sector instruction from my code I can write on it easily. my mean is that erasing and writing instruction work well individually but they don't work with together (In fact erasing instruction is done but write instruction is not done.).
Can you help me?
I am appreciate you if help me to solve this problem.
I am sure about my circuit. And also I checked all data that be sent by microcontroller to the flash by logic analyzer. they are identical with data sheet.
I have a problem in writing on SST25VF016B flash. I drive it with PIC16LF1516 by using a Software SPI.
My problem is that when I erasea a sector(4KB) of it I can not write any things on that sector any more.
And when I remove erasing sector instruction from my code I can write on it easily. my mean is that erasing and writing instruction work well individually but they don't work with together (In fact erasing instruction is done but write instruction is not done.).
Can you help me?
I am appreciate you if help me to solve this problem.
I am sure about my circuit. And also I checked all data that be sent by microcontroller to the flash by logic analyzer. they are identical with data sheet.
Code:
Write Byte Function:
void SPI_Flash_WriteByte(unsigned char Data , unsigned long int Address)
{
SPI_Flash_WREN(); //Enable Write Ability
FLASH_CS_PIN = 0; //Enable Flash Chip
SPI_Flash_SendByte(0x02);
SPI_Flash_SendByte((Address & 0xFFFFFF) >> 16); //Send 8 Upper Bits of Address
SPI_Flash_SendByte((Address & 0xFFFF) >> 8); //Send Next 8 Bits
SPI_Flash_SendByte(Address & 0xFF); //Send Last 8 Bits
SPI_Flash_SendByte(Data); //Send Data in Order to Store in Memory
FLASH_CS_PIN = 1; //Enable Flash Chip
SPI_Flash_WRDI(); //Disable Write Ability
}
erase sector Function:
void SPI_Flash_4KBErase(unsigned long int Address)
{
SPI_Flash_WREN(); //Enable Write Ability
FLASH_CS_PIN = 0; //Enable Flash Chip
SPI_Flash_SendByte(0x20); //Send "Chip Erase" Instruction
SPI_Flash_SendByte((Address & 0xFFFFFF) >> 16); //Send 8 Upper Bits of Address
SPI_Flash_SendByte((Address & 0xFFFF) >> 8); //Send Next 8 Bits
SPI_Flash_SendByte(Address & 0xFF); //Send Last 8 Bits
FLASH_CS_PIN = 1; //Disable Flash Chip
SPI_Flash_WRDI(); //Disable Write Ability
}
Last edited by a moderator: