AN2548 Freescale Semiconductor / Motorola, AN2548 Datasheet - Page 20

no-image

AN2548

Manufacturer Part Number
AN2548
Description
Serial Monitor Program for HCS12 MCUs
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
AN2548/D
User-Accessible
Utility Subroutines
WriteD2IX
Subroutine
Setting Up the SCI
Baud Rate
20
One of the most common ways to reduce code space is to develop a good set
of utility subroutines. A good utility subroutine is one that can be used in several
different contexts to perform some common task. The following utility
subroutines are provided for the user:
These routines are documented in the source code and previous pages. It is
recommended that users wishing to add to this jump table of instructions do so
in a manner that does not affect currently implemented commands.
The WriteD2IX subroutine saves code space similar to the way other
subroutines save space, but there is more important benefit from combining
this function into a subroutine. The Write_Byte command, the Write_Next
command, and the block write command all change the contents of memory
locations. By building these functions into a subroutine, it is possible to make
the operation use the address to intelligently decide whether to program
FLASH memory or simply write the data to the requested RAM or register
location. This routine also performs error checks to detect improper attempts to
program nonvolatile locations. The resulting routine ensures that FLASH
programming will be performed in exactly the same way no matter which
monitor command is responsible for the change. This helps improve code
reliability and reduces the amount of testing for the final program. If a change
is needed for the nonvolatile programming algorithm, it can be changed in this
one routine rather than having to locate three different places to correct the
program.
SCI baud rates are derived by dividing the bus frequency, so if the bus
frequency changes, the divider for the baud rate generator must change. This
monitor uses 115.2 kbaud. The baud rate must be within about ±4.5% of the
ideal rate. A modulo divider is controlled by the SCIBR (SBR12..SBR0) setting
in the SCIBDH and SCIBDL registers.
The formula for computing baud rate from bus frequency is:
Baud_Rate = Bus_Frequency / (SBR × 16)
Freescale Semiconductor, Inc.
For More Information On This Product,
PutChar
GetChar
EraseAllCmd
DoOnStack
WriteD2IX
Serial Monitor Program for HCS12 MCUs
Go to: www.freescale.com
MOTOROLA

Related parts for AN2548