unit b_maxflash8mb

MaxFlash 8Mbit writing and erasing routines

author: bocianu bocianu@gmail.com


Set of procedures to erase and write data onto MaxFlash 1Mbit cartridge.
Based on Steven Tucker's routines, placed into the public domain.
Now it works only with Am29F040 (or compatibile) modules, with sector size of 64K, but in future it might get extended for another chips.
Be notified that during erase and write operations all nonmaskable interrupts are disabled, so be careful, and enble them after, if they are needed.
This library is a part of 'blibs' - set of custom Mad-Pascal libraries.
https://gitlab.com/bocianu/blibs

Constants:

name:value:description:
MF_ZPLOCATION$D8starting location of reserved 4 bytes used by BurnPages routine

Interface:

name:description:
SetBank

procedure SetBank(bank: byte);


Switches cart to requested bank.
    parameters:
  • bank - cart bank number ($00-$7F)
SetSector

procedure SetSector(sec: byte);


Switches to first bank of specified sector.
    parameters:
  • sec - cart sector number ($00-$0F);
EraseChip

procedure EraseChip;


Erases whole Maxflash memory.
    EraseSector

    procedure EraseSector(sec: byte);


    Erases specified sector (8 banks = 64KB) of Maxflash memory.
      parameters:
    • sec - cart sector number ($00-$0F);
    BurnByte

    procedure BurnByte(bank:byte;addr:word;val:byte);


    Writes one byte into Maxflash memory:
      parameters:
    • bank - cart bank number ($00-$7F)
    • addr - cart address ($A000-$BFFF)
    • val - byte value
    BurnBlock

    procedure BurnBlock(bank: byte; src, dest, size: word);


    Writes block of data from computer memory to Maxflash cart.
      parameters:
    • bank - cart bank number ($00-$7F)
    • src - source memory address ($0000-$FFFF)
    • dest - cart address ($A000-$BFFF)
    • size - number of bytes to write
    BurnPages

    procedure BurnPages(sec, src, dest, pages:byte);


    Fastest procedure that copies whole memory pages from RAM into MaxFlash cart.
      parameters:
    • sec - cart sector number ($00-$0F);
    • src - starting source memory page ($00-$FF)
    • dest - cart memory address within selected sector ($00-$FF)
    • pages - number of pages to be copied