Load an S-Record file into memory. Data records of type S1 (16-bit MCU addresses) and S2 (linear 24-bit addresses) can be processed. S0-Records (comment lines) will be skipped. S8- and S9-Records are recognized as end-of-file mark. S2-Records use linear adresses according to Freescale guidelines. The valid address range for the MC9S12D64 starts at 0xF0000 (0x3C * 16KB) and ends at 0xFFFFF (0x40 * 16 KB - 1).
Keep in mind that I am using the MC9s12DP512. What steps do I need to take to progam to Flash memory?
The CPU can read every single byte of the microcontroller's resources - the type of memory does not matter. However, for write accesses, some rules have to be followed: Flash and EEPROM have to be erased before any write attempt. Programming is done by writing words (two bytes at a time) to aligned addresses. To form such aligned words, two subsequent bytes have to be combined. TwinPEEKs is aware of this, but the following problem can not be avoided by the monitor: The monitor is processing each S-Record line seperately. If the last address of such an S-Record is even, the 2nd byte to form a complete word is missing. TwinPEEKs will append an $FF byte in this case, so it is able to perform the word write. The problem occurs, if the byte stream continues with the following S-Record line. The byte, that was missing in the first attempt, CardS12 28 would require a second write access to the same (word) address - which is not allowed. As a consequence, a write error ("not erased") will be issued. To avoid this problem, it is necessary to align all S-Record data before programming. This can be done using the freely available Freescale Tool SRECCVT:
SRECCVT -m 0x00000 0xfffff 32 -o <outfile> <infile>
A detailed description of this tool is contained in the SRECCVT Reference Guide (PDF). Please note, that it is not possible to program or erase the part of Flash memory that contains the monitor code. Also, the last 16 bytes of the EEPROM block are reserved for system use.
Note:
Due to a mask set erratum of the MC9S12DP512 Mask Set 4L00M (and earlier) not only the monitor code in page $3F is write protected, but also an additional area starting at $B000 up to $BFFF in page $3B. Consequently, the monitor can not download user code to this region.