well. thanks for your replys.
i'm using MC9S08QG8 controller, whit a bus clock of 0,5MHz. The FCDIV value is 2, so the flash clock is 166KHz.
i have solved the reset problem when i erase a page (the dummy byte that i had using was an int), but i can't write my byte in the flash.
my .prm file, is like this:
NAMES END /* CodeWarrior will pass all the needed files to the linker by command line. But here you may add your own files too. *//* Here all RAM/ROM areas of the device are listed. Used in PLACEMENT below. */SEGMENTS MIROM = READ_ONLY 0xE000 TO 0xE1FF; // primera pagina para los valores de frecuencia e id. ROM = READ_ONLY 0xE200 TO 0xFFAD; Z_RAM = READ_WRITE 0x0060 TO 0x00FF; RAM = READ_WRITE 0x0100 TO 0x025F; ROM1 = READ_ONLY 0xFFC0 TO 0xFFCF;// CODE_RELOC = READ_ONLY 0xe200 TO 0xe240 RELOCATE_TO 0x0060; ENDPLACEMENT /* Here all predefined and user segments are placed into the SEGMENTS defined above. */ DEFAULT_RAM INTO RAM; DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM; /* ROM1 In case you want to use ROM1 as well, be sure the option -OnB=b is passed to the compiler. */ _DATA_ZEROPAGE, MY_ZEROPAGE, MIRAM INTO Z_RAM;ENDSTACKSIZE 0x50VECTOR 0 _Startup /* Reset vector: this is the default entry point for an application. */
and the write function:
//Escribe un word en la direccion de memoria flash que se le indicaunsigned char escribeWordFlash(unsigned int *far far_address,unsigned char data){ FSTAT = (FSTAT_FACCERR | FSTAT_FPVIOL); // clear errors (*far_address) = data; // Store desired data to address being programmed FCMD = 0x20; // Store programming command in FCMD FSTAT_FCBEF = 1; asm { nop nop nop nop }; if (FSTAT_FACCERR) return Access_Error; if (FSTAT_FPVIOL) return Protection_Error; while (!FSTAT_FCCF); //Wait for all commands to complete return 0;}
i disable the interrupts before the writes operation, and don't use the premicro debugger while i'm trying to write.
thanks again.
while((FSTAT & 0x80)!=0x80); // Wait till FCBEF is set
before the line (*far_address) = data;
Please refer Section 4.5.4 Access Errors in HCS08 Family Reference Manual, Rev. 2 Page 53
->Writing to a FLASH address while FCBEF is not set (A new command cannot be started until the command buffer is empty.)
And make sure the code is running from RAM rather than from FLASH.I have not worked on CodeWarrior IDE so I really cannot comment on the .prm file.
Its a wild guess.I'm not sure.In your .prm file you have commented the relocating part.
Regards,
Denn