Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] SST25VF016B Problem

Status
Not open for further replies.

Hadi.Dastour

Junior Member level 2
Junior Member level 2
Joined
Nov 27, 2017
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
183
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.
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:

Solution
Hello
My problem was solved.
Can you guess what that was?

SST25VF016B needs 30 mA to erase and write but my power supply provides just 25 mA .So the Problem was the needed power. Therefore I Connected it to a stronger supply and it worked very well.

My code does not have any mistakes.
Thanks
Yes I am sure. After erasing I read status register and wait until resetting busy bit in status register.
thank you for your response
--- Updated ---

I am very confused because I do every thing but I don't know why it does not work.
also at first I put erasing function in main code and execute it on microcontroller after that remove it and just put writing function. it works very well but together, writing instruction does not work.
 
Last edited:

Hi Mr Klaus
Thanks for your response.
I have added my perfect code.

C:
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
  while(SPI_Flash_RDSR() & 0x01);  //Wait for reseting busy bit
 
  SPI_Flash_WRDI();  //Disable Write Ability
}

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
  while(SPI_Flash_RDSR() & 0x01);  //Wait for reseting busy bit
 
  SPI_Flash_WRDI();  //Disable Write Ability
}

unsigned char SPI_Flash_RDSR(void)
{
  unsigned char SReg;
 
  FLASH_CS_PIN = 0;  //Enable Flash Chip
  SPI_Flash_SendByte(0x05);    //Send "Read Status Register" Instruction
  SReg = SPI_Flash_ReceiveByte();  //Receive Status Register
  FLASH_CS_PIN = 1;  //Disable Flash Chip
  return SReg;
}
 

Hello
My problem was solved.
Can you guess what that was?

SST25VF016B needs 30 mA to erase and write but my power supply provides just 25 mA .So the Problem was the needed power. Therefore I Connected it to a stronger supply and it worked very well.

My code does not have any mistakes.
Thanks
 

Solution
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top