AN2153 Freescale Semiconductor / Motorola, AN2153 Datasheet - Page 31

no-image

AN2153

Manufacturer Part Number
AN2153
Description
A Serial Bootloader for Reprogramming the MC9S12DP256 FLASH Memory
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Set Baud Rate
Command Code
S-Record Loader
Code
AN2153
MOTOROLA
of the start of the PPAGE window and the B accumulator with the
number of sectors to erase, the EraseSectors subroutine is called. In
addition to erasing the requested number of sectors, the VerfSector
subroutine is called to verify the erasure. Note that the VerfSector
subroutine verifies the erasure a word at a time because the erase verify
command built into the FLASH state machine will only operate on a
64-K block. After EraseBlk0 performs the erasure of the lower 48 K of
FLASH block zero, the lower 24 sectors ($8000–$EFFF) of the upper
16 K of block zero are erased.
The code comprising the set baud rate command is relatively simple.
The subroutine begins by displaying the baud rate change prompt and
then waiting for the operator to enter a baud rate selection. A range
check is performed on the entered character; if an invalid character is
entered, the prompt is redisplayed. If the selection is valid, the upper four
bits are masked off, one is subtracted from the lower four bits, and the
result is divided by two. The result is used as an index into the
BaudTable to retrieve the proper SCI0BD register value for the
selected baud rate.
Before switching to the newly selected baud rate, a message is
displayed prompting the operator to change the host terminal’s baud
rate. However, before the SCI0BD register is written with the new value,
the firmware must wait until the last character of the message is shifted
from the SCI0 transmit shift register. Once the last character of the
message is sent, the SCI0BD register is written with the new value and
the getchar subroutine is called to wait for an indication from the
operator that the host terminal baud rate has been changed. Finally, a
carriage return/line feed is sent to the terminal before returning to the
bootloader control loop.
The GetSRecord subroutine is used to receive a single S-record from
the host computer. GetSRecord begins by allocating space on the
stack for two local variables and initializing the X index register. The
SRecBytes variable is used to hold the converted value of the S-record
length field. This value includes the number of bytes contained in the
load address field, the length of the code/data field, and the length of the
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
Bootloader Software
Application Note
31

Related parts for AN2153