AN2432 Freescale Semiconductor / Motorola, AN2432 Datasheet - Page 8

no-image

AN2432

Manufacturer Part Number
AN2432
Description
LIN Sample Application for the MC68HC908EY16 Evaluation Board
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
AN2432/D
Software
8
LIN Sample Application for the MC68HC908EY16 Evaluation Board
The LIN LED monitor uses the Motorola/Metrowerks LIN drivers to handle the
LIN I/O protocol. Access to the drivers is via the API described in the LIN08
Driver User’s Manual (reference [2]). This manual is included on the CD
accompanying the evaluation board. An example of the use of this API is the
function call “LIN_GetMsg(0x20, Data_buf)”. This is all that is required to get
the data from the LIN message with an ID of $20 and put it into the array
Data_buf. This use of the LIN drivers results in the very simple application
software listed in section 7.
In order to respond to a master request command frame (ID 0x3C), the user
code has to include the function “LIN_Command()”. This is, for instance, how
the master would request all slave nodes to go into their low-power standby or
“sleep” mode. In this application, sleep mode is entered when there is no bus
activity and this function is just a dummy while(1).
The main software flow chart is shown in figure 2. Once the variables have
been declared, the CONFIG and I/O registers are initialised. The CONFIG1
value of 0x01 disables the COP while the CONFIG2 value of 0x29 configures
the MCU to use the crystal oscillator. In this configuration, the external canned
oscillator can also be used. At 9.8304MHz, it is appropriate for monitor mode
entry and is also the same frequency as the Cyclone/Multilink clock. By initially
using this frequency to develop the application, no software changes are
required between software debug and stand-alone running of the LIN node. If
a different target frequency is required then care should be taken when the
switch is made. The file slave.cfg (appendix IIc) shows the required settings to
configure the LIN drivers for a 9600 baud rate using 9.8304MHz and 8.0 MHz
oscillator frequencies.
Interrupts are enabled so that the LIN drivers, once initialised by “LIN_init()”,
can function properly. The main while loop uses the Time Base Module (TBM)
to facilitate a 244Hz repetition rate based on an 8MHz crystal. Once every
4.1ms the TBM overflow flag is set and the main loop is executed. The flag is
cleared and a counter used to flash an LED (D4) at 244/256 Hz to indicate that
the board is running correctly
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA

Related parts for AN2432