Hello BigMac,
as always, you've just solved my problem ;-))) Thank you very much indeed for your help, my code is working now!
I've read all about this topic on the forum earlier and I have been trying to adapt your QC8 routines to my application for a while . And yes, it is working now, after your explanation concerning the allocation of variables on the stack :-) Below is my .prm file for the QD2 (the QD2 has only 128 bytes RAM). I am still not quite sure if I really need 30 bytes for the SSTACK, but it is working now well.
The biggest advantage to me is, that your routine saves me some 450 bytes FLASH, compared to the readily available code beans (IFsh) from Processor Experts (which I got from this forum, too).
This is a huge improvement to me, since the QD has only 2kB FLASH, 0.5kB must be reserved for the page to be erased/written to and there's very little left for the actual code. Now I feel confident to finish my tasks even with this small µC.
(ups, I'm sorry, the code formatting tool here is not working for copy/paste snippets :smileywink:
/**************************************************************************************************
.prm file for S9S08QD2 with EEPROM emulation routines
**************************************************************************************************/
NAMES
END
SECTIONS
SSTACK = READ_WRITE 0x0080 TO 0x00B0; // software stack is 30 bytes wide
Z_RAM = READ_WRITE 0x00B0 TO 0x00FF;
FLASH_TO_RAM = READ_ONLY 0xFA00 TO 0xFA0F RELOCATE_TO 0x0080; //here resides the eeprom emulation routine
ROM = READ_ONLY 0xFA0F TO 0xFFA9;
PAGE_TO_BE_ERASED = READ_WRITE 0xF800 TO 0xF9FF; //reserve the page to be erased before eeprom emulation
END
PLACEMENT
DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM;
DEFAULT_RAM, // non-zero page variables
_DATA_ZEROPAGE, // zero page variables
MY_ZEROPAGE INTO Z_RAM;
FLASH_ROUTINE INTO FLASH_TO_RAM; //the eeprom emulation routine will be copied here
END
//INIT _EntryPoint // The entry point of the application. This function is generated into the CPU module.
STACKSIZE 0x0030 // Size of the system stack. Value can be changed on the "Build options" tab