AN2153 Freescale Semiconductor / Motorola, AN2153 Datasheet - Page 33

no-image

AN2153

Manufacturer Part Number
AN2153
Description
A Serial Bootloader for Reprogramming the MC9S12DP256 FLASH Memory
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
Serial
Communications
Code
AN2153
MOTOROLA
ensure that it is an ASCII hexadecimal character. If the character in the
B accumulator is a non-hexadecimal character, the subroutine returns a
“not equal” condition (CCR Z = 0). Otherwise, an “equal” condition
(CCR Z = 1) is returned. The CvtHex subroutine converts the ASCII
hexadecimal character in the B accumulator to a binary value. The result
remains in the B accumulator.
The serial communications routines utilize SCI0 to communicate with a
host computer. The routines utilize the SCI in an interrupt driven mode,
allowing reception of data from the host computer while the bootloader
is programming the on-chip FLASH memory. To prevent the possibility
of the receive buffer overflowing, the receive routines support XOn/XOff
handshaking with the host computer. Because the bootloader does not
send large amounts of data to the host computer, XOn/XOff
handshaking is not supported by the transmit routines.
To utilize the interrupt driven mode effectively, a circular buffer or queue
must be associated with both the transmitter and receiver. The queue
acts as an elastic buffer providing a software interface between the
received character stream and the MC9S12DP256. In addition to the
storage required by the transmit and receive queues, several other
pieces of data are required for queue management. The information
necessary to manage the queue consists of a way to determine the next
available storage location in each queue, the next available location or
piece of data in the queue, and a way to determine if a queue is full or
empty. Rather than utilize 16-bit pointers to manage the queues, the
communications routines employ four 1-byte variables. RxIn, RxOut,
TxIn, and TxOut are used in conjunction with 8-bit accumulator offset
indexed addressing to access data in the transmit and receive queues.
In addition, two 1-byte variables, RxBAvail and TxBAvail, are used to
keep track of the number of bytes available in each queue. When the
value in each of these variables is equal to the size of the queue, the
buffer is empty. When the value is zero, the queue is full. Using a byte
for the index does not allow support of queue sizes greater than 255
bytes. However, this should not pose severe restrictions for most
applications.
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
Bootloader Software
Application Note
33

Related parts for AN2153