AN2153 Freescale Semiconductor / Motorola, AN2153 Datasheet - Page 27

no-image

AN2153

Manufacturer Part Number
AN2153
Description
A Serial Bootloader for Reprogramming the MC9S12DP256 FLASH Memory
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Program
Command Code
AN2153
MOTOROLA
base address of the table contained in the X index register, produces the
absolute address of the first instruction of the requested command.
Using offsets in the command table in conjunction with calculating the
beginning of the table in a position independent manner, allows a
computed GOTO to be performed in a position independent manner.
Finally, the JSR instruction uses accumulator offset indexed addressing
to calculate the address of the command and calls the command as a
subroutine.
Upon return from the command, the value of the global variable
ErrorFlag is examined. If it contains a value of zero, the command
completed without any errors. In this case, the code branches back to
the top of the command loop where the bootloader prompt is
redisplayed. If, however, an error occurred during command execution,
the value in ErrorFlag is used as an index into a table of offsets to null
terminated error strings. Calculation of the absolute address of the error
string is performed in much the same manner as the calculation of the
absolute address of the command. After displaying the error message,
the code branches back to the top of the command loop where the
bootloader prompt is redisplayed.
The firmware required to implement the FLASH programming command
consists of two subroutines. The first subroutine, ProgFlash, is called
through the command table. This subroutine coordinates the activities
required by the ProgFBlock subroutine which performs the actual
programming of the FLASH memory. The ProgFlash subroutine
begins by calling the GetSRecord subroutine which is used to receive
a single S-record from the host computer. Having received an valid
S-record, the subroutine performs several checks to ensure that the
S-record meets the programming requirements of the MC9S12DP256.
Because the MC9S12DP256’s FLASH may only be programmed an
align word at a time, both the code/data field length and the load address
must be even numbers. If either value is odd, an error code is stored in
the ErrorFlag global variable and the FLASH programming operation
is terminated.
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
Bootloader Software
Application Note
27

Related parts for AN2153