1 Reply Latest reply on Oct 29, 2018 7:35 PM by MeenakshiR_71

    SMIF 4-Byte Addressing for S25FL512S




      I am attempting set up the SMIF related files in my PSoC 6 project to enable the four byte addressing mode for accessing the S25FL512S. I configured things by using CE220823 as a guide and am using a modified version of the smif_mem.c/smif_mem.h files in my design.


      This is what I understand so far about the address: a .cymem file is selected in the SMIF Configuration Tool, which is used to generate a .cysmif file. That cysmif file is then used in generating the code in the "Generated_Source/SMIF" directory. This is where the parameter specifying the number of address bytes is finally generated. The cymem file has a line for NumberOfAddress that percolates through this chain to be the numOfAddrBytes line in cy_smif_memconfig.c.


      I have created a new cymem file by copying the built-in file for the S25FL512S. It is identical aside from changing the PartNumber field and the NumberOfAddress lines and adding a comment noting those changes. I can see the change from the NumberOfAddress line reflected in cy_smif_memconfig.c to show that there are four address bytes. However, when I make the change to the .cymem file to use a 4 byte address and attempt to run a simple test loop (erase sector 0, read 512 bytes back, write 512 bytes to sector, read 512 bytes back values), the output is not as expected. After the erase, bytes aren't zero and writing bytes doesn't change their value. No functions appear to fail during this, just the data being returned illustrates that the functions aren't being executed correctly.


      My question is this: assuming that all user-made functions are changed to reflect a four-byte address in Big Endian order (with the high byte in address[0], etc), what all changes need to be made to permanently use the SMIF connected flash with four byte addresses in the standard MMIO mode?


      Thanks in advance,


        • 1. Re: SMIF 4-Byte Addressing for S25FL512S

          Hello Josh,


          Yes your understanding of the cymen file is correct.


          Now coming to the issue you are facing - before you update the Number of address bytes value, you should understand the extended address mode of the S25FL512S device. The commands that the file generates support extended addressing but by default these commands are meant to work with 3-byte addressing and not 4. In order for you to use the same commands with 4-byte addressing, you will need to set the EXTADD bit of Bank Address Register (see flash datasheet). For this you need to send a Write register command like shown below -


          Cy_SMIF_Memslot_CmdWriteEnable(base, memDevice, context);


          uint8 bankRegisterValue = 0x80; //sets EXTADD bit in the Bank register


          Cy_SMIF_TransmitCommand( base, 0x17, /* 0x17 - BRWR, bank register write command */









          After you have enabled EXTADD bit/mode, you will be able to use 4-byte address instead of 3-byte with the same commands. Note that there are dedicated Erase/Read/Write commands for 4-byte addressing. If you are interested in supporting both, then you can implement addition Read/Erase/Write APIs using the 4-byte address commands - refer to flash datasheet for details.


          One other note, when you perform an erase, the value read is not 0. It is 0xFF i.e. erase sets the bit not clears and a write can ONLY clear a bit and not set. This is typical for any NOR flash device. This is the reason you need an erase (to set all bits) and then perform a write (clear the bits that are 0) .


          Hope this helps.



          Meenakshi Sundaram R