Fcsmscan08 background and assembly example, Fcsdemo can program – Freescale Semiconductor Microcontrollers User Manual

Page 277

Advertising
background image

HC08 Full Chip Simulation

Configuration Procedure

277

Microcontrollers Debugger Manual

FCSMSCAN08 Background and Assembly
Example

The MSCAN08 peripheral is a scalable control area network (CAN) 2.0 compliant device
that allows microcontrollers to exchange data between themselves at high speeds. This is
done through a high-speed serial link that is deterministic and reliable. CAN devices are
often utilized in automobiles, where multiple microcontrollers need to be connected into a
network. The CAN specification indicates that any unit on the bus can be a master at any
time, where they can send a message to another unit whenever they wish if the bus is free
to do so. All of these messages can be setup through the CAN I/O commands built into the
simulator. This section goes through an example of this, showing how the simulator can be
used to test out code for driving the CAN peripheral

Listing 11.1

is an example assembly program that exercises the CAN 2.0 peripheral on the

68HC908AZ60. The source assembly file can be download from P&E Microcomputer
website at www.pemicro.com. With minor modifications this assembly file can be added
and compiled as a part of your Freescale project. It initializes the CAN peripheral on the
microcontroller for operation and uses interrupts from the CAN peripheral to service
requests from other controllers. Once the code is compiled and loaded into the
microprocessor that you are using, simulator commands can be used to emulate the CAN
messages that come from the host. Let us first break down what is being done in the
example program.

FCSDemo CAN Program

This code simply sets up the CAN controller to be ready to receive CAN messages
intended for hexadecimal address 0x01234567. Note that this peripheral allows the user to
setup filters for address matching, where only certain bit fields of the address need to
match in order to receive the data. In our case we just setup the filters for 32-bit exact
match. An interrupt service routine is created for the CAN peripheral and is used to collect
messages that are received.

The code also tries to send out three fixed messages in memory out to the network. Each
of these messages has three different locations that they are sent to. The priorities for the
messages are also setup to be different, to show how prioritization works with the CAN
peripheral.

Listing 11.1 68HC908AZ60 MSCAN Demonstration Application

; 68HC908AZ60 MSCAN Demonstration Application
; (C)opyright P&E Microcomputer Systems, 2000

$pagewidth 120t

RAMStart equ $0050 ; start of RAM for AZ60

Advertising