Freescale Semiconductor Microcontrollers User Manual

Page 286

Advertising
background image

HC08 Full Chip Simulation

Configuration Procedure

286

Microcontrollers Debugger Manual

which give the addresses of peripheral registers on the microcontroller. Following this
comes the variable declarations for pointers, counters, and buffers for the received data.

In the Flash ROM, the message descriptions are given, which indicate the destination
address, message priority, message length, and the actual data. Note that the number of
data bytes can be variable sizes from 0-8. The information needed in these descriptions
can be found in the CAN specification and the 68HC908AZ60A datasheet.

After the message descriptions come the actual code, where there are some procedures for
handling different tasks. The first is the initialization procedure, which sets up the registers
in the CAN peripheral for the intended operation. The CAN peripheral is also enabled at
the end of the routine. After this comes the start of the application in the MAIN_INIT
procedure, where we call the initialization routines, initialize the pointers and counters,
and wait for an interrupt to occur. There is one interrupt service routines for the CAN
peripheral in this code which is triggered when the peripheral receives CAN messages
specifically intended for it. Note that this application is totally interrupt driven, where the
code is driven by any events that take place through the CAN peripheral.

The end of the code shows the interrupt vectors for the microcontroller, where the CAN
interrupts and the RESET vector are included. All other vectors are pointed to a dummy
interrupt service routine that simply returns from the interrupt.

Once the above mentioned assembly code is compiled as a part of the Freescale project,
one can step through it in the Full Chip Simulation mode. The execution starts
automatically at the reset location within the code. We are now ready to start debugging
the code.

First, we need to step through the beginning of the code in the simulator in order to allow
the code to initialize the microcontroller and the CAN peripheral and get ready to start
receiving CAN packets from the network. So, the user needs to step through the beginning
of the code until they get to the main loop with the t command.

At this point we are ready for CAN packets to come into the device. There are three
specific commands in the simulator for testing the CAN peripheral: CANIN, CANOUT,
and CANCLR (see detailed MSCAN commands description below). The CANIN
command allows a user to specify messages coming into the CAN peripheral. The
CANOUT command allows a user to see the packets that were sent out from the CAN
peripheral. The CANCLR command allows the user to clear all input and output buffers of
CAN packets.

Now we can use the CANIN command to specify CAN packets that come from the
network to our device. When a user types this command in the simulator, the CAN IN
window appears as shown in

Figure 11.26

. There are no CAN packets specified yet in the

window, so we will enter some into it.

Advertising