User Tools

Site Tools


manual:ports:hcs12

NXP HCS12

To configure your software program to work with the OpenBLT bootloader, some modifications are needed. These modifications are detailed in this section. Note that the demo programs are working examples that you can refer to, to determine how to implement these modifications.

Bootloader size

For a typical HCS12 bootloader the flash memory from 0xe800 to 0xffff (6 kbyte) is reserved. The linker descriptor file of the user program should be modified to make sure no code or data is placed in this memory region by the linker:

Checksum location

A 16-bit checksum value is programmed by the bootloader at the end of a programming session. Upon startup, the bootloader verifies the correctness of this checksum to determine if a valid user program is present and can be started.

The user program must reserve space for this 16-bit checksum value. The bootloader programs this value at the begin of the interrupt vector table. To reserve this space, simply enter one extra dummy entry into the interrupt vector table:

Vector table location

The bootloader itself occupies the location where normally the user program's vector table is located. All interrupts from the user program are rerouted by the bootloader to a fixed location that is available to the user program, which is from 0xe780 to 0xe7ff. The vector table relocation can be achieved by changing the ROM start address of the user program's vector table. Note that the size of the user program's vector table is 2 bytes larger than usual as a result of adding the 16-bit checksum. Therefore the start address should be 0xe780 - 0x0002 = 0xe77e:

RAM remapping

The bootloader changes the location of RAM in the memory map for compatibility between different HCS12 derivatives. It remaps the RAM to always end at 0x3fff. The linker descriptor file of the user program should be modified to make sure RAM data is placed at the correct address.

For example, an HCS12C128 derivative has 4 kbyte RAM. After reset it is mapped from 0x0000 to 0x0fff. The bootloader remaps this to 0x3000 to 0x3fff:

S-record with 24-bit linear addresses

The HCS12 port supports only 24-bit linear addresses. A linear address is calculated as follows: linear address = (page number * page size) + offset address in page.

Take for example the 2nd byte on page 0x3e. Page 0x3e is a fixed flash page of 16 kbyte visible in the memory map from 0x4000 to 0x7fff. Its physical address is therefore 0x4001. It's linear address = (0x3e * 16384) + 1 = 0xF8001.

The S-record of the user program that can be programmed with the Microboot utility must therefore contain S-records with 24-bit linear addresses. Tools exist for converting S-records to this 24-bit linear address format. Search for “Sreccvt.exe” with Google.

When using the CodeWarrior development environment this is achieved quite easily. Overwrite the burner.bbl file that is added by the project wizard with the one found in the demo program (\Target\Demo\HCS12_Evbplus_Dragon12p_CodeWarrior\Prog\cmd\burner.bbl). This will create an S-record with the *.sx extension with correctly formatted 24-bit linear addresses.

manual/ports/hcs12.txt · Last modified: 2022/11/07 09:27 by voorburg