Saturday, March 19, 2022

Programming requirements for 29F400 flash memory chip

ERASING SECTORS USES SECTOR NUMBERS, NOT BYTE/WORD ADDRESSES

The Sector Erase commands use the high bits of the address, bits A17 down to A12, to specify a sector number. For the larger blocks, those that span 16K, 32K or 64K bytes, the low order bits don't matter. The first block is just 8K, so its sector number in binary is B000000 but the second block, spanning 16KB, responds to either B000010 or B000011, the third responds to B000100 or B000101, and so forth. 

The command sequence sets up the sector number in bits 17 to 12, all others are ignored when the command is executed. For the data I need to load, we will only use five sectors, thus I will issue this just five times using the addresses B000000, B000010, B000011, B000100, and B001000.  After this is complete, the contents of the first 128KB of the flash memory are all set to xFF. 

CHIP AND SECTOR PROTECTION POSSIBILITIES

The chip offers ways to protect sectors or the entire chip so that you can't inadvertently update or erase the contents. There are commands to protect the chip and sequences to remove the protection, but that also requires +12V be applied to the RESET# line which isn't available on the IOB PCB; if the chip is ever protected it cannot be released while on the board. There are protections per sector that can be applied, removed and tested. Fortunately, the chip comes with the protections off and I will leave them that way. 

NAVIGATING OCTAL, HEX, WORD AND BYTE ADDRESSES

In planning and execution of the flash loading project, I will have to deal with some complications related to multiple ways to refer to the same value. The PDP-8 is a 12 bit word machine and the general practice is to represent numbers in base 8 (octal), groups of 3 bits each. On the other hand, the flash memory documentation and the usual practice with the majority of computers is to use groups of four bits to represent values in hexadecimal, base 16. 

Even if we deal exclusively in hex, there is still some duality because the flash chip is inherently a word oriented design, words being 16 bits, but it has a byte mode. The addressing for locations in the chip is done with 18 bits, the most significant being A17 and the least is A0. If only address bit A3 is a 1, this is address x00008 or decimal 8. 

If in byte mode, there is an additional address bit A(-1) that is actually selecting which half of the 16 bit word is being selected. That means that in byte mode, the same word that was x00008 in regular mode is address x00010 in byte mode. This matters because there are times when we are required to set up address x00555 while in word mode, but address x00AAA in byte mode. This is the same location, but in byte mode we are adding in A(-1) to the right side of the address. 

WAKEUP SEQUENCES NEEDED BEFORE COMMANDS TO THE CHIP

For some reason, the controller inside the chip that handles the commands needs to see a special sequence of addresses and data values in order to wake up and accept the actual commands. The first cycle, you have to send address x00AAA and data of xAA (address x00555 on the A17-A0 lines and then a 0 on the A(-1) line. Second cycle gets x00555 and data of x55. For the sector erase command, it also needs the same two cycle sequence after the second command and before the actual sector number is sent. 

INTERROGATING STATUS OF THE OPERATIONS

The data bits from the chip are used to output status during and after these command operations. There is one output signal RD/BY# that goes off when the chip is busy and doesn't go on until the command completes. Too, you can look at the data bits for more information. The particular meaning depends on the command being executed.

COMMAND SEQUENCE TO ERASE A SECTOR

It takes six cycles to send the command sequence, after which you have to keep waiting until the RD/BY# signal goes active when the erase is complete. Here is what is sent on the address and data lines:

    ADDRESS                        DATA

    x00AAA                            xAA

    x00555                               x55

    x00AAA                            x80     (erase sector command)

    x00AAA                            xAA

    x00555                                x55

    sector address A17-A12    x30

COMMAND SEQUENCE TO WRITE A BYTE

It takes four cycles to request that the chip update a byte, after which you have to wait for RD/BY# to go active to signal that the change is complete.

    ADDRESS                        DATA

    x00AAA                            xAA

    x00555                               x55

    x00AAA                            xA0        (write a byte command)

    address of byte                   byte value


No comments:

Post a Comment