Well, I think I figured out the correct changes to the PRN file and got the code to load and run. The copy to RAM portion is working as well, but I am still unable to write a value to a Flash location. I'm assuming the line:
PTFD &= ~0x01
is intended to indicate an error in writing to flash by writing a 0 to Port F bit 0, which, in my case, conveniently illuminates an LED on my demo board. If I examine the FSTAT register immediately after stepping past that line I see no errors flagged. I have tried writing to a variety of flash locations but still have no success. My Fbus is 4.19MHz and FDIV is being written with 0x13. My code is below:
#include <hidef.h>
#include "derivative.h"
#include "S08_Flash.h"
#define LED1 PTFD_PTFD0
#define LED2 PTFD_PTFD1
long Flash_mem = 0xF800; // Defines the location in flash memory to erase/write
byte Flash_contents @ 0xF800;
byte data = 0xda; // changed from ' '
char *Flash_byte;
int i;
int n;
void main(void)
{
// I added this code:
ICGC1 = 0x38; // Configure Fbus = 4.19MHz
ICGC2 = 0x00;
/* Port F Bit 1 active when error occurs */
PTFDD |= 0x03;
PTFD |= 0x03;
EnableInterrupts;
flash_init();
copyinRAM(); /* Copy flash routine to RAM */
if (flash_erase( Flash_mem)) /* Erase flash sector - change from 0xF800 */
PTFD &= ~0x01;
if (flash_program( Flash_mem, data)) /* Program single byte - changed from 0xF800*/
PTFD &= ~0x01;
for( ; ; ) {
for(i=0;i<= Flash_contents;i++); //This portion of code will flash LED1 at a rate
for(n=0; n<2; n++); //tied to the value of the data value written to
//the Flash location. It is a simple form of
LED1 =~ LED1; //user feedback.
__RESET_WATCHDOG();
} /* Loop always */
}
THANKS!