AN2153 Freescale Semiconductor / Motorola, AN2153 Datasheet - Page 28

no-image

AN2153

Manufacturer Part Number
AN2153
Description
A Serial Bootloader for Reprogramming the MC9S12DP256 FLASH Memory
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Freescale Semiconductor, Inc.
Application Note
Next, the received S-record type is checked. Reception of an S8 or S9
S-record terminates the program FLASH command returning to the
bootloader’s control loop where the prompt is redisplayed. S0 records,
designated as header records, do not contain any program or data and
are simply ignored. Because the linear S-record addresses for the
MC9S12DP256 begin at $C0000 as shown in
Figure
10, only S2
S-records may be used to program the on-chip FLASH. Because the
GetSRecord subroutine is capable of receiving S0, S1, S2, S8 and S9
S-records, the program FLASH command is terminated and an error
code is returned in the ErrorFlag global variable if an S1 record is
received.
After checking the received S-record type, a range check is performed
on the S-record load address to ensure it is within the range of the
on-chip FLASH minus the size of the 4 K protected area containing the
bootloader. When performing the range check, the load address is first
checked against SRecLow, the lowest valid S-record address for the
on-chip FLASH. However, when checking against the upper limit,
SRecHi, the number of code/data bytes contained in the S-record must
be added to the load address before the comparison is performed. This
ensures that even though the initial load address is less than the upper
limit, none of the S-record code/data falls outside the upper limit.
Finally, the ProgFlash subroutine uses the S-record load address to
calculate the PPAGE number and PPAGE window address using the
formulas in
Figure
11. After initializing the PPAGE register, the PPAGE
value is used to calculate a value for the block select bits. Closely
examining the PPAGE values and the block numbers as shown in
Figure
1, it can be determined that the block number for any of the
PPAGE values corresponds to the one’s complement of bits two and
three of the block’s corresponding PPAGE value. After writing the proper
value to the block select bits in the FCNFG register, the ProgFBlock
subroutine is called to program the received S-record data into the
FLASH. If no errors occurred during the programming operation, the
code branches to the label FSendPace where an ASCII asterisk
character is sent to the host computer to indicate that S-record data was
successfully programmed into the FLASH.
AN2153
28
MOTOROLA
For More Information On This Product,
Go to: www.freescale.com

Related parts for AN2153