how to write buffer programming for s29gl512T

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lixu_4619546
Level 1
Level 1

Hello :

     now my mcu is  stm32f407 use s29gl512T as external storage, and reference datasheet

pastedImage_0.png

my code is

NOR_Status FSMC_NOR_ProgramBuffer(uint16_t* pBuffer, uint32_t WriteAddr, uint32_t NumHalfwordToWrite)

{

uint32_t lastloadedaddress = 0x00;

uint32_t currentaddress = 0x00;

uint32_t endaddress = 0x00;

/* Initialize variables */

currentaddress = WriteAddr;

endaddress = WriteAddr + NumHalfwordToWrite - 1;

lastloadedaddress = WriteAddr;

/* Issue unlock command sequence */

NOR_WRITE(ADDR_SHIFT(0x00555), 0x00AA);

NOR_WRITE(ADDR_SHIFT(0x02AA), 0x0055);

/* Write Write Buffer Load Command */

NOR_WRITE(ADDR_SHIFT(WriteAddr), 0x0025);

NOR_WRITE(ADDR_SHIFT(WriteAddr), (NumHalfwordToWrite - 1));

/* Load Data into NOR Buffer */

while(currentaddress <= endaddress)

{

/* Store last loaded address & data value (for polling) */

lastloadedaddress = currentaddress;

NOR_WRITE(ADDR_SHIFT(currentaddress), *pBuffer++);

currentaddress += 2;

}

NOR_WRITE(ADDR_SHIFT(lastloadedaddress), 0x29);

return(FSMC_NOR_GetStatus(Program_Timeout));

}

but then I read flash it is all 0x0000

0 Likes
1 Reply
Apurva_S
Moderator
Moderator
Moderator
100 likes received 500 replies posted 250 solutions authored

Hi Li Xuhui,

Thank you for contacting Cypress Semiconductor.

I would like to ask you a few questions -

  1. Have you been able to read the flash successfully? You can read a fresh sector of flash where you have not performed any program operation previously and confirm if the data being read is 0xFF so we can rule the possibility that read operation is faulty.
  2. Can you confirm that you are performing the write operation on an erased sector? If the sector is not erased before programming and the data in the sector is 0x00 you will not be able to program a different data pattern to the flash.

A few suggestions from our side are -

  1. As a sample for ProgramBuffer implementation, you can go through our Low Level Driver for Parallel NOR Flash. You can download the driver from here - https://www.cypress.com/documentation/software-and-drivers/low-level-driver-nor-flash?source=search&...
  2. While calculating the endaddress = WriteAddr + NumHalfwordToWrite - 1; instead of considering half words to write (i.e. number of bytes) could you please change it to number of words to write and let us know what happens? In our LLD, the word count has been implemented as the number of words to be programmed.

Best Regards,

Apurva

0 Likes