Chapter 4: Software
CAN-Engine
_____________________________________________________________________________________
4-14
4.4
Functions in AEEE.OBJ
The 512-byte serial EEPROM (24C04) provided on-board allows easy storage of non-volatile program
parameters. This is usually an ideal location to store important configuration values that do not need to be
changed often. Access to the EEPROM is quite slow, compared to memory access on the rest of the
controller.
Part of the EEPROM is reserved for TERN use specifically for this purpose.
Addresses 0x00 to 0x1f on the EEPROM is reserved for system use, including configuration information
about the controller itself, jump address for Step Two, and other data that is of a more permanent nature.
The rest of the EEPROM memory space, 0x20 to 0x1ff, is available for your application use.
ee_wr
Arguments: int addr, unsigned char dat
Return value: int status
This function is used to write the passed in dat to the specified addr. The return value is 0 in success.
ee_rd
Arguments: int addr
Return value: int data
This function returns one byte of data from the specified address.
4.5
Controller-Area-Network (CAN) Interface
The CAN-Engine optionally provides the Philips SJA1000 stand-alone CAN controller. This controller
allows the CAN-E to communicate over a Controller Area Network, a popular protocol and bus standard for
microcontroller communication.
BACKGROUND
Controllers communicate over a CAN network using frames, at a specified baud rate. Controllers can send
and receive equally on the CAN network, with the underlying chipset handling collision detection and basic
buffering.
In simplified form, each transmitted frame consists primarily of:
-
Recipient address (11-bits);
-
Data bytes (0-8 bytes);
-
Protocol information (CRC consistency, and other bits indicating frame properties).
A controller initializes the CAN chipset by defining the class of messages it wants to receive. This is done
by defining an 8-bit address value as well as an 8-bit mask. The masked address value is used to compare
to the highest 8-bits of all incoming frames; qualifying frames are received and inserted into a buffer for the
application to handle. Unlike many other networking schemes, frames travelling on a CAN bus do not
identify who the sender is, and does not necessarily indicate a specific recipient.
Transmitted and received packets are buffered both in the hardware chipset (up to 64 bytes), as well as the
interrupt-driven TERN firmware drivers (buffer size defined by application).
TERN firmware drivers are configured to use the SJA1000 in BasicCAN mode only. More advanced
features may be available by directly accessing the SJA1000’s control registers. The datasheet for the
SJA1000 may be found on the TERN development CD in the directory \tern_docs\parts.