I had checked the location of the flash programming function in the debugger, and it is correctly stored in RAM at 0x100. Here's a code snippet from the PRM file:
SEGMENTS /* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */
Z_RAM = READ_WRITE 0x0080 TO 0x00FF;
RAM = READ_WRITE 0x0158 TO 0x17FF;
RAM1 = READ_WRITE 0x1870 TO 0x20EF;
/* unbanked FLASH ROM */
ROM = READ_ONLY 0x20F0 TO 0x7FFF;
ROM1 = READ_ONLY 0xC101 TO 0xFF9B;
/* INTVECTS = READ_ONLY 0xFF9C TO 0xFFFF; Reserved for Interrupt Vectors */
/* banked FLASH ROM */
PPAGE_0 = READ_ONLY 0x008000 TO 0x00A0EF; /* PAGE partially contained in ROM segment */
PPAGE_2 = READ_ONLY 0x028000 TO 0x02BFFF;
PPAGE_4 = READ_ONLY 0x048000 TO 0x04BFFF;
PPAGE_5 = READ_ONLY 0x058000 TO 0x05BFFF;
PPAGE_6 = READ_ONLY 0x068000 TO 0x06BFFF;
PPAGE_7 = READ_ONLY 0x078000 TO 0x07BFFF;
/* PPAGE_1 = READ_ONLY 0x018000 TO 0x01BFFF; PAGE already contained in segment at 0x4000-0x7FFF */
/* PPAGE_3 = READ_ONLY 0x038000 TO 0x03BFFF; PAGE already contained in segment at 0xC000-0xFFFF */
FLASH_TO_RAM = READ_ONLY 0xC000 TO 0xC100 RELOCATE_TO 0x100;
END
I've defined the flash clock as follows:
#define BUS_CLOCK 14745600
#if BUS_CLOCK > 12800000
#define FLASH_CLOCK (unsigned char)((BUS_CLOCK/1600000) + 0x40)
#else
#define FLASH_CLOCK (unsigned char)(BUS_CLOCK/200000)
#endif
The vfnFlashInit() routine that was provided by Carlos uses the FLASH_CLOCK to set the FCDIV. So it would appear I am setting these up correctly...