<< Previous | Index | Next >> | |
|
The flash memories listed in the table below have been qualified for use with the Rabbit 2000 microprocessor. Starting with Dynamic C version 7.20 large sector flash devices (sectors greater than 4096 bytes) are supported. To incorporate a large-sectored flash into an end product, the best strategy is have a small-sectored development board.
IMPORTANT: The rapidly changing market for flash devices may affect availability. The inclusion of a flash device in the following table does not speak to its availability.
- Package Types:
1. 32-pin PDIP 2. 32-pin PLCC
3. 32-pin TSOP (8 mm × 14 mm) 4. 32-pin TSOP (8 mm × 20 mm)
5. 44-pin PLCC 6. 48-pin TSOP (8 mm × 14 mm)- These flash devices are supported as of the Dynamic C version listed, but have not all been tested with those versions. 512KB flash in particular may not work with versions prior to 7.04, but a software patch is available from Rabbit tech support for 512KB flash support under versions 6.57 and 7.03.
- Dynamic C Versions 6.04-6.1x:
TheFLASH_SIZE
parameter in theJRABBIOS.C
file needs to be changed to reflect the correct number of 4K pages for the selected device. By default, theFLASH_SIZE
parameter contains a 0x20 that corresponds to a 128K x 8 device with thirty-two 4K pages of flash. Dynamic C versions 6.5x and greater determine the flash size automatically and no code change is required.11.1 Supporting Other Flash Devices
If a user wishes to use a flash memory not listed in the above tables, but still uses the same standard JEDEC write sequences as one of the supported flash devices, the existing Dynamic C flash libraries may be able to support it simply by modifying a few values in the BIOS. Specifically, three modifications need to be made:
- The flash device needs to be added to the list of known flash types. This table can be found by searching for the label
FlashData
in the fileLIB\BIOSLIB\FLASHWR.LIB
. The format is described in the file and consists of the flash ID code, the sector size in bytes, the total number of sectors, and whether the flash is written one byte at a time or one entire sector at a time.- Near the top of the main BIOS file (
BIOS\RABBITBIOS.C
for most users), in the line#define FLASH_SIZE _FLASH_SIZE_
- change
_FLASH_SIZE_
to a fixed value for your flash (the total size of the flash in 4096-byte pages).
- If a version of Dynamic C prior to 7.02 is being used, the macro
_SECTOR_SIZE_
near the top ofLIB\BIOSLIB\FLASHWR.LIB
needs to be hard-coded in a manner similar to step 2 above. In the line :#define MAX_FLASH_SECTORSIZE _SECTOR_SIZE_
_SECTOR_SIZE_
should be replaced with the sector size of your flash in bytes.Note that prior to Dynamic C 7.20, the BIOS only supported flash devices with equally-sized sectors of either 128, 256, 512, 1024, or 4096 bytes (i.e., small sector flash) If you are using an older version of Dynamic C (prior to version 7.20) and your flash device does not fall into that category, it may be possible to support it by rewriting the BIOS flash functions; see Section 11.2Writing Your Own Flash Driver for more information.
Starting with Dynamic C 7.20, large sector flash devices are supported by the BIOS. Typically large sector flash devices have a variety of sector sizes on a single chip.
11.2 Writing Your Own Flash Driver
If a user wishes to install a flash memory that cannot be supported by following the steps in the above section (for example, if it uses a completely different unlock/write sequence), two functions need to be rewritten for the new flash. This section explains the requirements of these two functions:
_InitFlashDriver
and_WriteFlash
. They will need to replaced in the library that implements the flash driver,FLASHWR.LIB
.Below is the C
struct
used by the flash driver to hold the required information about the flash memory installed. The_InitFlashDriver
function is called early in the BIOS to fill thisstruct
before any accesses to the flash.struct {
char flashXPC; // XPC required to access flash via XMEM
int sectorSize; // byte size of one flash memory sector
int numSectors; // number of sectors on flash
char writeMode; // write method used by the flash
void *eraseChipPtr; // pointer to erase chip function in RAM
// (eraseChipPtr is currently unused)
void *writePtr; // ptr to write flash sector function (RAM)
} _FlashInfo;The field
flashXPC
contains the XPC required to access the first flash physical memory location via XMEM address E000h. The pointerwritePtr
should point to a function in RAM to avoid accessing the flash memory while working with it. You will probably be required to copy the function from flash to a RAM buffer in the flash initialization sequence.The field
writeMode
specifies the method that a particular flash device uses to write data. Currently, only two common modes are defined: "sector-writing" mode, as used by the SST SST29 and Atmel AT29 series (writeMode=1); and "byte-writing" mode, as used by the Mosel/Vitelic V29 series (writeMode=2). All other values ofwriteMode
are currently undefined, although they may be defined by Rabbit Semiconductor as new flash devices are used._InitFlashDriver
This function is called from the BIOS. A bitmap of quadrants mapped to flash (0x01, 0x02, 0x04, 0x08 correspond to the 1st-4th quadrants, 0x0C = the topmost two quadrants) is passed to it in HL.
This function needs to perform the following actions:
- Load
_FlashInfo.flashXPC
with the proper XPC value to access flash memory address 00000h via XMEM address E000h. The quadrant number for the start of flash memory is passed to the function in HL and can be used to determine the XPC value, if desired. For example, if your flash is located in the third memory quadrant, the physical address of the first flash memory location is 80000h. 80000h - E000h = 72000h, so the value placed into_FlashInfo.XPC
should be 72h.- Load
_FlashInfo.sectorSize
with the flash sector size in bytes.- Load
_FlashInfo.numSectors
with the number of sectors on the flash._FlashInfo.writePtr
should be loaded with the memory location in RAM of the function that will perform that action. The function will need to be copied from flash to RAM at this time as well.- This function should return zero if successful, or -1 if an error occurs.
_WriteFlash
This function writes exactly one sector of data from a buffer in RAM to the flash memory, aligned along a flash sector boundary. _WriteFlash is called from the BIOS (the user will normally call higher-level flash writing functions) as well as several libraries, and should be written to conform to the following requirements:
- For versions of Dynamic C prior to 7.02, it should assume that the source data is located at the logical RAM address passed in BC. In all later versions of Dynamic C, a fixed 4096-byte block of XMEM is used for the flash buffer, which can be accessed via macros located at the top of
FLASHWR.LIB
. These macros includeFLASH_BUF_PHYS
, the unsigned long physical address of the buffer;FLASH_BUF_XPC
andFLASH_BUF_ADDR
, the logical address of the buffer via the XMEM window; andFLASH_BUF_0015
andFLASH_BUF_1619
, the physical address of the buffer broken down to be used with the LDP opcodes.- It should assume that the flash address to be written to is passed as an XMEM address in A:DE. The destination must be aligned with a flash memory sector boundary.
- It should check to see whether the sector being written contains the ID or user blocks. If so, it should exit with an error code (see below). Otherwise, it should perform the actual write operation required by the particular flash used.
- Interrupts should be turned off (set the interrupt level to 3) whenever writes are occurring to the flash. Interrupts should not be turned back on until the write is complete -- an interrupt may attempt to access a function in flash while the write is occurring and fail.
- It should not return until the write operation is finished on the chip.
- It should return a zero in HL if the operation was successful, a -3 if a timeout occurred during the wait, or a -4 if an attempt was made to write over the ID block.
Rabbit 2000 Designer's Handbook |
<< Previous | Index | Next>> | rabbit.com |