sometimes these forums can be more or less useful but it really depends on the attitude of all of us.
reference: mc9s08rd32dwe processor CodeWarrior hc(s)08 3.1
anyway(s) flash page erase byte write problemo resolved. basically assembly code interface had two errors, well lets say three.
-the assembly code required an unsigned int of address and a Byte of data to be written to and the c language program was writting this data to the wrong address
-some interrupt, possibly due to my dwn rev version of CW, seemed to over wite the data even if it were written to the correct locations.
-no documentation, especially the assembly code. the stuff i saw looked very odd, tho i am sure it was working when submitted. i actuall saw somethig like this:
((unsigned char (*) (int, unsigned char))(Ram_Routine)))
//the assembly routine express as a initilized array, not the lack of any comments except the address locations address 1 = (unsigned int)address address2 = (Byte)data
#pragma DATA_SEG _RAMROUTINE. Note here because something was over writting address 1&2 i moved these to the end of the array, see locations three locations 0x00,0x00,0x00. by the way Ram_Routine[] was linker located top of ram in the *.prn file. so note address 1&2 address&data are set to 0x0843 and 0x0845 and 0x845 is the last byte of ram.
unsigned char [] = {
0xc6,0x18,0x25,0xa5,0x10,0x27,0x07,0x45,0x18,
//address 1 //address 2
0x25,0xf6,0xaa,0x10,0xf7,0x32,0x08,0x43,0xc6,0x08,0x45,
0xf7,0xa6,0x40,0x45,0x18,0x25,0xe7,0x01,0xf6,0xaa,0x80,
0xf7,0x9d,0x9d,0x9d,0x9d,0xc6,0x18,0x25,0xc6,0x18,0x25,
0xa5,0x40,0x27,0xf9,0x81,0x00,0x00,0x00};
#pragma DATA_SEG DEFAULT
//usage of the above assembly code is at 2 levels, a C language interface and code in main.c
//C language interafce
//*************>>> erase Flash page at the the given address ********
void Flash_Erase (unsigned int FlashAddress){
*(unsigned int*)0x843 = 0xE001; //test code i elected to set address immediate because
*(Byte*)0x845 = 0x55; //of the over write problem.
Ram_Routine[22] = 0x40;//flash command
_asm jsr Ram_Routine;}
//*******>>> stores a byte of data onto the Flash at the given address ******
void Flash_Program(Byte data){
*(Byte*)0x845=data;
Ram_Routine[22] = 0x20;
_asm jsr Ram_Routine;}
//************************
//main.c calles everything like this:
Flash_Erase ((unsigned int)0xE001) //must page erase first
*(unsigned int*)0x843=0xE001; //now able to write once to any byte in page
Flash_Program((Byte)0xCD);
//linker command file settings, see the section RAMROUTINE
SEGMENTS
Z_RAM = READ_WRITE 0x0046 TO 0x00FF;
RAM = READ_WRITE 0x0100 TO 0x04FF;
PATCH_RAM = READ_WRITE 0x0500 TO 0x06FF;
XBITTOGGLE= NO_INIT 0x07C8 TO 0x07CF;
TEMP = NO_INIT 0x07D0 TO 0x07DF;
FLASHVAR = NO_INIT 0x07E0 TO 0x07E9;
RAM2 = READ_WRITE 0x07EA TO 0x0816;
RAMROUTINE= READ_WRITE 0x0814 TO 0x0845;
PLACEMENT
DEFAULT_ROM INTO ROM;
DEFAULT_RAM INTO RAM, RAM2;
_PATCH_RAM INTO PATCH_RAM;
_FLASHSECURITY INTO NV_REG;
_ROM_VARIABLES INTO MYROM;
_TABLE INTO KBTABLE;
_FLASHVARS INTO FLASHVAR;
_RAMROUTINE INTO RAMROUTINE;
_DATA_ZEROPAGE, MY_ZEROPAGE INTO Z_RAM;
_TV_TABLE INTO TV_DATA;
_TEMP INTO TEMP;
_XBITTOGGLE INTO XBITTOGGLE;
END
Message Edited by jah on 2006-09-2910:36 AM