AN2153 Freescale Semiconductor / Motorola, AN2153 Datasheet - Page 36

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
interrupt is generated. XOffSent is used by the receive interrupt service
routine to ensure that only a single XOff character is sent to the host after
the space available in the queue falls below the value of XOffCount.
XOffSent is also used by the getchar subroutine to determine if an
XOn should be sent after each character is removed from the queue.
Finally, notice that if the queue becomes full, the received byte is simply
discarded.
The transmit interrupt service routine, TxIRQ, has the responsibility of
removing a byte from the transmit data queue and sending it to the host
computer. Before sending a character from the transmit queue,
SendXOff is checked. If it contains a non-zero value, an XOff character
is immediately sent to the host. Sending the XOff character before
sending data that may be in the transmit queue ensures data flow from
the host is stopped before the receive queue overflows. Notice that if the
queue becomes empty after a character is transmitted, transmitter
interrupts are disabled.
The last two major routines rounding out the serial communication code
are the getchar and putchar subroutines. The getchar subroutine’s
main function is to retrieve a single character from the receive queue and
return it to the calling routine in the B accumulator. Notice that if the
receive queue is empty, the getchar subroutine will wait until a
character is received from the host. Because this action may not be
desirable for some applications, a utility subroutine, SCIGetBuf, can be
called to determine if any data is in the receive queue. This small
subroutine returns, in the B accumulator, a count of the number of data
bytes in the receive queue. In addition to managing the receive queue
variables each time a character is removed from the queue, the
getchar subroutine checks the state of XOffSent and the number of
characters left in the receive queue to determine if an XOn character
should be sent to the host computer. If an XOff character was previously
sent and the number of characters left in the receive queue is less than
XOnCount, an XOn character is sent to the host by calling the putchar
routine.
AN2153
36
MOTOROLA
For More Information On This Product,
Go to: www.freescale.com

Related parts for AN2153