Information in this document is provided in connection with Intel products. No license, express or implied, by estoppel or
rwise, to any intellectual property rights is granted by this document. Except as provided in Intel’s Terms and Conditions
othe
of
Sale for such products, Intel assumes no liability whatsoever, and Intel disclaims any express or implied warranty, relating
to
sale and/or use of Intel products including liability or warranties relating to fitness for a particular purpose, merchantability,
or infringement of any patent, copyright or other intellectual property right. Intel products are not intended for use in medical,
life saving, or life sustaining applications.
l may make changes to specifications and product descriptions at any time, without notice.
Inte
Designers must not rely on the absence or characteristics of any features or instructions marked "reserved" or "undefined."
Inte
l reserves these for future definition and shall have no responsibility whatsoever for conflicts or incompatibilities arising
from future changes to them.
The 87C196CB and 8XC196NT microprocessors may contain design defects or errors known as errata which may cause the
products to deviate from published specifications. Current characterized errata are available on request.
Contact your local Intel sales office or your distributor to obtain the latest specifications and before placing your product order.
Copies of documents which have an ordering number and are referenced in this document, or other Intel literature may be
obta
ined by calling 1-800-548-4725 or by visiting Intel’s website at http://www.intel.com.
This document is a supplement to the 8XC196NT Microcontroller User’s Manual. It describes
the differences between the 87C196CB and the 8XC196NT. For information not found in this
supplement, please consult the 8XC196NT Microcontroller User’s Manual (order number
272317) or the 87C196CB datasheet (87C196CA/87C196CB 20 MHz Advanced 16-Bit CHMOSMicrocontroller with Integrated CAN 2.0, order number 272405).
1.1MANUAL CONTENTS
This supplement contains several chapters, an appendix, a glossary, and an index. This chapter,
Chapter 1, provides an overview of the supplement. This section summarizes the contents of the
remaining chapters and appendixes. The remain der of this chapter provides references to related
documentation.
Chapter 2 — Architectural Overview — compares the features of the 87C196CB with those of
the 8XC196NT and describes the 87C196CB’s internal clock circuitry.
Chapter 3 — Memory Partitions — describes the addressable memory space of the 84 -pin and
100-pin 87C196CB, lists the peripheral special-function registers (SFRs), and provides tables of
WSR values for windowing higher memory into the lower register file for direct access.
Chapter 4 — Standard and PTS Interrupts — describes the additional interrupts for the CAN
(controller area network) peripheral and the SFRs that support those interrupts.
Chapter 5 — I/O Ports — describes the port 0 and EPORT differences for the 100-pin
87C196CB. Both port 0 and the EPORT are implemented as eight-bit ports on the 100-pin
87C196CB, but as four-bit ports (like the 8XC196NT) on the 84-pin 87C196CB.
Chapter 6 —Analog-to-digital ( A/D) Converter— illustrates the SFRs that are affected by the
implementation of port 0 as an eight-bit port.
Chapter 7 — CAN Serial Communications Controller — describes the 87C196CB’s integrated CAN controller and explains how to configure it. This integrated periphera l is similar to Intel’s
standalone 82527 CAN serial communications controller, supporting both the standard and extended message frames specified by the CAN 2.0 protocol parts A and B.
Chapter 8 — Special Operating Modes — illustrates the clock control circuitry of the
87C196CB.
1-1
87C196CB SUPPLEMENT
Chapter 9 — Interfacing with External Memory — discusses differenc es in the bus timing
modes supported by the 8XC196NT and the 87C196CB.
Chapter 10 — Programming the Nonvola tile Memory — describes the memory maps and rec-
ommended circuits to support programmi ng of the 87C196CB’s 56 Kbytes of OTPROM.
Appendix A — Signal Descriptions — describes the additional signals implemented on the
87C196CB.
Glossary — defines terms with special me aning used througho ut this supplement.
Index — lists key topics with page number referenc es .
1.2RELATED DOCUMENTS
Table 1-1 lists additional documents that you may find useful in desig ning systems incorporating
the 87C196CB microcontroller.
T able 1-1. Related Documents
Title and DescriptionOrder Number
8XC196NT Microcontroller User’s Manual
Automotive Products
87C196C B 20 MHz Advanced 1 6-Bit CHM OS Microcontroller with
Integrated CAN 2.0 (
handbook231792
datasheet)
272317
272405
1-2
Architectural
Overview
2
CHAPTER 2
ARCHITECTURAL OVERVIEW
This chapter describes architectural differences between the 87C196CB and the 8XC196NT.
Both the 8XC196NT and the 87C196CB are designed for high-speed calculations and fast I/O.
With the addition of the CAN (controller area network ) peripheral, the 8 7C196CB reduces pointto-point wiring requirements, making it well-suited to automotive and factory automation applications.
The 87C196CB is available in eith er an 84-p in or a 100-pin p ackage. Th e 84-pin 8 7C196CB, like
the 8XC196NT, has up to 2 0 external address lines, enabling access to 1 Mbyte of linear add ress
space. The 100-pin 87C196CB has four additional pin s available for ex ternal add ress lines. With
all 24 external address lines connected, the 100-pin 87C196CB can access 16 Mbytes of linear
address space.
2.1DEVICE FEATURES
Table 2-1 lists the features of the 8XC196NT and the 87C196CB. The 87C196CB implements
more OTPROM, more register RAM, four additional A/D channels, and the CAN peripheral. The
100-pin 87C196CB also implements four additional EPORT pins.
Table 2-1. Features of the 8XC196NT and 87C196CB
8XC196NT68 0 or 32 K1 K512561024140
87C196CB84 56 K1.5 K512 561028 142
87C196CB100 56 K 1.5 K512601028182
†
Register RAM amount includes the 24 bytes allocated to the core SFRs and stack pointer.
2-1
87C196CB SUPPLEMENT
2.2BLOCK DIAGRAM
Figure 2-1 shows the major blocks within the device. The 8XC196NT and 87C196CB have the
same peripheral set with the exception of the CAN (controller area network) periphe ral, which is
unique to the 87C196CB. The CAN peripheral manages communications between multiple network nodes. This integrated periph eral is similar to Intel’s standalon e 82527 CAN serial communications controller, supporting both the standard and extended message frames specified by the
CAN 2.0 protocol parts A and B.
Core
Clock and
Power Mgmt.
SSIO
OTPROM
Code/Data
RAM
EPAI/O
A/DSIO
Interrupt
Controller
PTS
WDT
Slave
Port
CAN
A3179-01
Figure 2-1. 87C196CB Block Diagram
2.3INTERNAL TIMING
The 87C196CB’s clock circuitry ( Figure 2-2 ) implements phase-locked loop and clock multiplier
circuitry, which can substantially increase the CPU clock rate while using a lower-frequency input clock. The clock circuitry accepts an input clock signal on XTAL1 provided by an external
crystal or oscillator. Depending on the value of the PLLEN pin, this frequency is routed either
through the phase-locked loop and multiplier or directly to the divide-by-two circuit. The multiplier circuitry can quadruple the inpu t frequency (F
) before the frequency (f) reache s the di-
XTAL1
vide-by-two circuitry. The clock generators accept the divided input frequency (f/2) from the
divide-by-two circuit and produce two nonoverlapping internal timing signals, PH1 and PH2.
These signals are active when high.
2-2
NOTE
This manual uses lowercase “f” to represent the internal clock frequency. For
the 87C196CB, f is equal to either F
XTAL1
or 4F
, depending on the clock
XTAL1
multiplier mode, which is controlled by the PLLEN input pin.
XTAL1
F
XTAL1
Disable
PLL
(Powerdown)
ARCHITECTURAL OVERVIEW
Phase
Comparator
Filter
Phase-
locked
Oscillator
Phase-locked Loop
Clock Multiplier
Peripheral Clocks (PH1, PH2)
CLKOUT
CPU Clocks (PH1, PH2)
A3168-01
XTAL2
PLLEN
Disable
Oscillator
(Powerdown)
XTAL1
F
XTAL1
4F
Disable Clock Input
(Powerdown)
f
Divide-by-two
Circuit
f
2
Clock
Generators
Disable Clocks
(Powerdown)
Disable Clocks
(Idle, Powerdown)
Figure 2-2. Clock Circuitry
The rising edges of PH1 and PH2 generate the internal CLKOUT signal (Figure 2-3). The clock
circuitry routes separate internal clock signals to the CPU and the peripher als to provid e flexibility in power management. It also outputs the CLKOUT signal on the CLKOUT pin. Because of
the complex logic in the clock circuitry, the signal on the CLKOUT pin is a delayed version of
the internal CLKOUT signal. This delay varies with temperature and voltage.
2-3
87C196CB SUPPLEMENT
XTAL1
PH1
PH2
CLKOUT
tt
1 State Time
1 State Time
Phase 1Phase 2
Phase 1Phase 2
A0805-01
Figure 2-3. Internal Clock Phases
The combined period of phase 1 and phase 2 of the internal CLKOUT signal defines the basic
time unit known as a state time or state. Table 2-2 lists state time durations at various frequencies.
The following formulas calculate the freq uency of PH1 and PH2, the d uration of a state time, and
the duration of a clock period (t).
P H1 (in MHz)
f
-- -PH2==State Time (in µs)
2
2
-- -=t
f
1
-- -=
f
Because the device can operate at many frequencies, this manual defines time requir ements (such
as instruction execution times) in terms of state times rather than specific measurements.
Datasheets list AC characteristics in terms of clock periods (t; sometimes called T
osc
).
Figure 2-4 illustrates the timing relationships between the input freq uency (F
), the operating
XTAL1
frequency (f), and the CLKOUT signal with each PLLEN pin conf iguration. Ta ble 2-3 details the
relationships between the input frequency (F
), the PLLEN pin, the operating frequency (f),
XTAL1
the clock period (t), and state times.
2-4
XTAL1 (5 MHz)
CLKOUT
XTAL1 (5 MHz)
CLKOUT
ARCHITECTURAL OVERVIEW
PLLEN = 0
t = 80ns
f
T
XHCH
PLLEN = 1
t = 20ns
f
T
XHCH
A3170-01
Figure 2-4. Effect of Clock Mode on CLKOUT Frequency
Table 2-3. Relationships Between Input Frequency, Clock Multiplier, and State Times
This chapter describes the differences in the address space of the 87C196CB from that of the
8XC196NT. The 87C196CB has 56 Kbytes of one-time-programmable read-only memory (OTPROM), while the 8XC196NT is available with 32 Kbytes. The 87C196CB also has an additional
512 bytes of register RAM.
The 87C196CB is available in eith er an 84-p in or a 100-pin p ackage. Th e 84-pin 8 7C196CB, like
the 8XC196NT, has up to 2 0 external address lines, enabling access to 1 Mbyte of linear add ress
space. The 100-pin 87C196CB has four additional pin s available for ex ternal add ress lines. With
all 24 external address lines connected (A23:16 and AD15:0), the 100-pin 87 C196CB can access
16 Mbytes of linear address space.
3.1MEMORY MAP, SPECIAL-FUNCTION REGISTERS, AND WINDOWING
Table 3-1 compares the register file addresses of the 8XC196NT and 87C196CB. Table 3-2 is a
memory map of the 87C196CB. Table 3-3 lists the 87C196CB’s peripheral SFRs (these are the
same as those of the 8XC196NT). Table 3-4 lists the CAN peripheral SFRs, which are unique to
the 87C196CB. Tables 3-5 through 3-9 provide the information necessary to window higher
memory into the lower register file for direct access.
Table 3-1. Register File Memory Addresses
Device and Hex
Address Range
CBNT
1DFF
1C00
03FF
0100
00FF
001A
0019
0018
0017
0000
.
.
—Register RAMIndirect, indexed, or windowed direct
03FF
0100
00FF
001A
0019
0018
0017
0000
Upper register file (register RAM)Indirect, indexed, or windowed direct
Lower register file (register RAM)Direct, indirect, or indexed
Lower register file (stack pointer)Direct, indirect, or indexed
Lower register file (CPU SFRs)Direct, indirect, or indexed
DescriptionAddressing Modes
3-1
87C196CB SUPPLEMENT
Table 3-2. 87C196CB Memory Map
Hex
Address
FFFFFF
FF2080
FF207F
FF2000
FF1FFF
FF0600
FF05FF
FF0400
FF03FF
FF0100
FF00FF
FF0000
FEFFFF
0F0000
0EFFFF
010000
00FFFF
002000
001FFF
001FE0
001FDF
001F00
001EFF
001E00
001DFF
001C00
001BFF
000600
0005FF
000400
0003FF
000100
0000FF
000000
†
For the 87C196CB, the program and special-purpose memory locations (FF2000-FFF FFFH) can reside
Program memory (After a device reset, the first instruction fetch
is from FF2080H)
Special purpose memory
External device (memory or I/O) connected to address/data busIndirect, indexed, extended
Internal code and data RAM
(mapped identically into pages FFH and 00H)
External device (memory or I/O) connected to address/data busIndirect, indexed, extended
Locations xF0000-xF00FFH are reserved for in-circuit emulator s. Do not use these locations except to
initialize them. Except as otherwise noted, initialize unused program memory locations and reserved
memory locations to FFH.
†††
These locations can be either external memory (CCB2.2=0) or a copy of the OTPROM (CCB2.2=1).
DescriptionAddressing Modes
†
†
Indirect, indexed, extended
Indirect, indexed, extended
Indirect, indexed, extended
Indirect, indexed, extended
††
†††
Indirect, indexed, extended
Indirect, indexed, extended
Indirect, indexed, extended,
windowed direct
Indirect, indexed,
windowed direct
Indirect, indexed, extended
Indirect, indexed, extended
Indirect, indexed,
windowed direct
3-2
MEMORY PARTITIONS
Table 3-3. 87C196CB Peripheral SFRs
Ports 0, 1, 2, and 6 SFRsTimer 1, Timer 2, and EPA SFRs
Locations 1FE0–1FFFH contain memory-mapped SFRs that cannot be access ed through a window.
Reading these locations through a window returns FFH; writing these locations through a window has no
effect.
WSR Value for
128-byte Window
(0080–00FFH)
†
1FH
1EH
1DH
1CH
1BH
1AH
19H
18H
3-10
MEMORY PARTITIONS
Table 3-8. Windows (Continued)
Base Address
Upper Register File
03E0H5FH
03C0H5EH
03A0H5DH
0360H5BH
0340H5AH
0320H59H
02E0H57H
02C0H56H
02A0H55H
0260H53H
0240H52H
0220H51H
01E0H4FH
01C0H4EH
01A0H4DH
0160H4BH
0140H4AH
0120H49H
†
Locations 1FE0–1FFFH contain memory-mapped SFRs that cannot be access ed through a window.
Reading these locations through a window returns FFH; writing these locations through a window has no
effect.
WSR Value
for 32-byte Window
(00E0–00FFH)
WSR Value
for 64-byte Window
(00C0–00FFH)
2FH
2EH0380H5CH
2DH
2CH0300H58H
2BH
2AH0280H54H
29H
28H0200H50H
27H
26H0180H4CH
25H
24H0100H48H
WSR Value for
128-byte Window
(0080–00FFH)
17H
16H
15H
14H
13H
12H
3-11
87C196CB SUPPLEMENT
Table 3-9 . WSR Settings and Direct Address es for Windowable SFRs
The interrupt structure of the 87C196CB is the same as that of the 8XC196NT. The only difference is that INT13, which was reserved on the 8XC196NT, supports the CAN peripheral.
Table 4-1 lists the 87C196CB’s interrupts sources, default priorities (30 is highest and 0 is lowest), and vector addresses. Figures 4-1 and 4-2 illustrate the interrupt m ask and pend ing registers.
Table 4-1. Interrupt Sources, Vectors, and Priorities
PTS service is not recommended because the PTS cannot determine the source of shared interrupts.
EPA
x
INT00FF2000H00PTS00†FF2040H15
PTS Service
†
FF205AH28
4-1
87C196CB SUPPLEMENT
INT_MASK1
Address:
Reset State:
0013H
00H
The interrupt mask 1 (INT_MASK1) register enables or disables (masks) individual interrupt requests.
(The EI and DI instructions enable and disable servicing of all maskable interrupts.) INT_MASK1 can
be read from or written to as a byte register. PUSHA saves this register on the stack and POP A
restores it.
70
NMIEXTINTCANRITISSIO1SSIO0CBF
7:0Setting a bit enables the corresponding interru pt.
The standard interrupt vector locations are as follows:
Bit Mnemonic InterruptStandard Vector
†
NMI
Nonmaskable InterruptFF203EH
EXTINTEXTINT PinFF203CH
CAN CAN Peripheral FF203AH
RISIO ReceiveFF2038H
TISIO TransmitFF2036H
SSIO1SSIO 1 TransferFF2034H
SSIO0SSIO 0 TransferFF2032H
CBFSlave Port Command Buffer FullFF2030H
†
NMI is always enabled. This nonfunctional mask bit exists for design symmetry with the
INT_PEND1 register. Always write zero to this bit.
Figure 4-1. Interrupt Mask 1 (INT_MASK1) Register
INT_PEND1
Address:
Reset State:
When hardware detects a pending interrupt, it sets the corresponding bit in the interrupt pending
(INT_PEND or INT_PEND1) registers. When the vector is taken, the hardware clears the pending bit.
Software can generate an interrupt by setting the corresponding interrupt pending bit.
70
NMIEXTINTCANRITISSIO1SSIO0CBF
0012H
00H
7:0Any set bit indicates that the corresponding interrupt is pending. The interrupt bit is cleared
when processing transfers to the corresponding interrupt vector.
The standard interrupt vector locations are as follows:
The I/O ports of the 87C196CB are functionally ide ntically to those of the 8XC196NT. Howev er,
the 87C196CB implements all eight pins of port 0, and the 100-pin 87C196CB also implements
all eight pins of the EPORT. The associated registers have been modified to include bits corresponding to the upper nibble of the ports. Table 5-1 provides an overview of the 8XC196CB’s
I/O ports. Figure 5-1 illustrates the port 0 pin state register, a nd Figures 5- 2 through 5-5 illu strate
the EPORT registers.
Table 5-1. 87C196CB Input/Output Ports
PortBitsTypeDirect ionAssociated Peripheral(s)
Port 08StandardInput-onlyA/D converter
Port 18StandardBidirectional EPA and timers
Port 28 StandardBidirect ionalSIO, interrupts, bus control, clock gen.
Port 38Memory-mappedBidirectional Address/data bus
Port 48Memory-mappedBidirectional Address/data bus
Port 58Memory-mappedBidirectional Bus control, slave port
Port 68StandardBidirectional EPA, SSIO
Each bit of the port 0 pin input (P0_PIN) register reflects the current state of the corresponding pin,
regardless of the pin configuration.
70
PIN7PIN6PIN5PIN4PIN 3PIN 2PIN1PIN0
Bit
Number
7:0PIN7:0Port 0 Pin
Bit
Mnemonic
Function
x
Input Value
This bit contains the current state of P0.
x
.
Address:
Reset State:
1FDAH
XXH
Figure 5-1. Port x Pin Input (Px_PIN) Register
5-1
87C196CB SUPPLEMENT
EP_DIR
In I/O mode, each bit of the extended port I/O direction (EP_DIR) register controls the direction of the
corresponding pin. Clearing a bit configures a pin as a complementary outpu t; setting a bit configures
a pin as either an input or an open-drain output. (Open-drain outputs require external pull-ups).
Any pin that is configured for its extended-address function is forced to the complementary output
mode except during reset, hold, idle, and powerdown.
70
PIN7PIN6PIN5PIN4PIN3PIN 2PIN1PIN0
Bit
Number
7:0PIN7:0Extended Address Por t Pin
Bit
Mnemonic
x
Direction
This bit configures EPORT.
input/open-drain output.
0 = complementary output
1 = input or an open-drain output
x
as a complementary output or an
Function
Address:
Reset State:
1FE3H
FFH
Figure 5-2. Extended Port I/O Direction (EP_DIR) Register
EP_MODE
Each bit of the extended port mode (EP_MODE) register controls whet her the corres ponding pin
functions as a standard I/O port pin or as an extended-address signal. Setting a bit configures a pin as
an extended-address signal; clearing a bit configures a pin as a standard I/O port pin.
70
PIN7PIN6PIN5PIN4PIN 3PIN 2PIN1PIN0
Address:
Reset State:
1FE1H
FFH
Bit
Number
7:0PIN7:0Extended Add ress Port Pin
Bit
Mnemonic
This bit determines the mode of EPORT.
0 = standard I/O port pin
1 = extended-address signal
Figure 5-3. Extended Port Mode (EP_MODE) Register
5-2
Function
x
Mode
x
:
I/O PORTS
EP_PIN
Each bit of the extended port input (EP_PIN) register reflects the current state of the corresponding
pin, regardless of the pin configuration.
70
PIN7PIN6PIN5PIN4PIN 3PIN 2PIN1PIN0
Bit
Number
7:0PIN7:0Extended Add ress Port Pin
Bit
Mnemonic
Function
x
Input
This bit contains the current state of EPORT.
Address:
Reset State:
x
.
1FE7H
XXH
Figure 5-4. Extended Port Input (EP_PIN) Register
EP_REG
Each bit of the extended port data output (EP_REG) register contains data to be driven out by the
corresponding pin. When a pin is configured as standard I/O (EP_MODE.
write to EP_REG is immediately visible on the pin.
During nonextended data accesses, EP_REG contains the value of the memory page that is to be
accessed. For compatibility with software tools, clear the EP_REG bit for any EPORT pin that is
configured as an extended-address signal (EP_MODE.
70
PIN7PIN6PIN5PIN4PIN3PIN 2PIN1PIN0
x
set).
Address:
Reset State:
x
= 0), the result of a CPU
1FE5H
00H
Bit
Number
7:0PIN7:0Extended Add ress Port Pin
Bit
Mnemonic
If EPORT.
out.
If EPORT.
If EPORT.
the memory page to be accessed by nonextended instructions.
x
is to be used as an output, write the data that it is to drive
x
is to be used as an input, set this bit.
x
is to be used as an address line, write the correct value for
Figure 5-5. Extended Port Data Output (EP_REG) Register
Function
x
Output
5-3
Analog-to-digital
(A/D) Converter
6
CHAPTER 6
ANALOG-TO-DIGITAL (A/D) CONVERTER
6.1ADDITIONAL A/D INPUT CHANNELS
The 87C196CB’s A/D converter is functionally identical to that of the 8XC196NT, but it has
eight analog input channels instead of four. Table 6-1 lists the A/D signals. Figure 6-1 describes
the command register and Figure 6-2 describes the result register.
Table 6-1. A/D Converter Pins
Port PinA/D Signal
P0.7:0ACH7:0IAnalog inputs. See the “Voltage on Analog Input Pin”
—ANGNDGNDReference Ground
—V
PWRReference Voltage
REF
A/D Signal
Type
specification in the datasheet.
Must be connected for A/D converter and port operation.
Must be connected for A/D converter and port operation.
Description
6-1
87C196CB SUPPLEMENT
AD_COMMAND
Address:
Reset State:
1FACH
C0H
The A/D command (AD_COMMAND) register selects the A/D channel number to be converted,
controls whether the A/D converter starts imme diately or w ith an EPA com mand, and selects the
conversion mode.
70
——M1M0GOACH2ACH1ACH0
Bit
Number
Bit
Mnemonic
Function
7:6—Reserved; for compatibility with future devices, write zeros to these bits.
5:4M1:0A/D Mode
†
These bits determine the A/D mode.
M1M0Mode
0010-bit conversion
018-bit conversion
10threshold detect high
11threshold detect low
3GOA/D Conversion Trigger
††
Writing this bit arms the A/D converter. The value that you write to it
determines at what point a conversion is to start.
Write the A/D conversion channel number to these bits. The 87C196CB
has eight A/D channel inputs, numbered 0–7.
†
While a threshold-detection mode is selected for an analog input pin, no other conversion can be
started. If another value is loaded into AD_COMMAND, the threshold-detection mode is disabled
and the new command is executed.
††
It is the act of writing to the GO bit, rather than its value, that starts a conversion. Even if the GO bit
has the desired value, you must set it again to start a conversion immediately or clear it again to
arm it for an EPA-initiated conversion.
6-2
Figure 6-1. A/D Command (AD_COMMAND) Register
ANALOG-TO-DIGITAL ( A/D) CONVERTER
AD_RESULT (Read)
The A/D result (AD_RESULT) register consists of two bytes. The high byte contains the eight mostsignificant bits from the A/D converter. The low byte contains the two least-significant bits from a tenbit A/D conversion, indicates the A/D channel number that was used for the conversion, and indicates
whether a conversion is currently in progress.
5:4—Reserved. These bits are undefined.
3STATUSA/D Status
2:0ACH2:0A/D Channel Number
Bit
Mnemonic
Function
These bits contain the A/D conversion result.
Indicates the status of the A/D converter. Up to 8 state times are required
to set this bit following a start command. When testing this bit, wait at
least the 8 state times.
0 = A/D is idle
1 = A/D conversion is in progress
These bits indicate the A/D channel number that was used for the
conversion. The 87C196CB has eight A/D channel inputs, numbered
0–7
Address:
Reset State:
1FAAH
7F80H
Figure 6-2. A/D Result (AD_RESULT) Register — Read Format
6-3
CAN Serial
Communications
Controller
7
CHAPTER 7
CAN SERIAL COMMUNICATIONS CONTRO LL ER
The 87C196CB has a peripheral not found in the 8XC196NT — the CAN (controller area network) peripheral. The CAN serial communications con troller manages commu nications between
multiple network nodes. This integrated peripheral is similar to Intel’s standalone 82527 CAN
serial communications controller. It supports both the standard and th e extend ed message fram es
specified by CAN 2.0 protocol parts A and B developed by Robert Bosch, GmbH. This chapter
describes the integrated CAN controller and explains how to configure it. Consult Appendix A,
“Signal Descriptions,” for detailed descriptions of the signals discussed in this chapter.
7.1CAN FUNCTIONAL OVERVIEW
The integrated CAN contr oller transfers messages b etween network nodes acco rding to the CAN
protocol. The CAN protocol uses a multiple-master, contention-based bus configuration, which
is also called CSMA/CR (carrier sense, multiple access, with collision resolution). Each CAN
controller’s input and output pins are connected to a two-line CAN bus through which all communication takes place (Figure 7-1).
ABS
196Cx
device
Engine
196Cx
device
Transmission
196Cx
device
RXCAN
TXCAN
RXCAN
TXCAN
RXCAN
TXCAN
Bus
Driver
Bus
Driver
Bus
Driver
CAN_L
CAN_H
CAN_L
CAN_H
CAN_L
CAN_H
CAN_L
CAN_H
CAN_L
CAN_H
CAN Bus
Bus
Driver
Bus
Driver
Rx0
Tx0
Security System
Rx0
Tx0
Dashboard
82527
82527
Bus
CPU
Bus
CPU
Figure 7-1. A System Using CAN Controllers
A2588-02
7-1
87C196CB SUPPLEMENT
This bus configuration reduces point-to-point wiring requirements, making the CAN controller
well suited to automotive and factory autom ation ap plications. In ad dition, it relieves the CPU of
much of the communications burden while providing a high level of data integrity through error
management logic.
The CAN controller (Figure 7-2) has one input pin, one output pin, control and status registers,
and error detection and management logic.
Bit Timing Registers
Control Register
Status Register
Interrupt Register
7-2
RXCAN
Bus
Driver
Global
Mask
Registers
Mask 15
Register
RAM
CAN Bus
Message
Objects 1-14
Message
Object 15
Error
Management
Logic
Figure 7-2. CAN Controller Block Diagram
TXCAN
Bus
Driver
2
A2590-02
CAN SERIAL COMMUNICATIONS CONTROLLER
7.2CAN CONTROLLER SIGNALS AND REGISTERS
Table 7-1 describes the CAN controller’s pins, and Table 7-2 describes the contro l and status registers.
Table 7-1. CAN Controller Signals
SignalTypeDescription
RXCANIReceive
This signal carries messages from other nodes on the CAN bus to the CAN controller.
TXCANOTransmit
This signal carries messages from the CAN controller to other nodes on the CAN bus.
Table 7-2. Control and Status Registers
Register
Mnemonic
CAN_BTIME0
CAN_BTIME1
CAN_CON
††
†
†
†
CAN_EGMSK1E08H, 1E09H,
CAN_INT1E5FH CAN Interrupt Pending
CAN_MSG
CAN_MSG
†
The CCE bit in CAN_CON must be set to enable write access to the bit timing registers.
††
In register names, x = 1–15; in addresses, y = 1–F.
x
CFG1Ey6H Message Object x Configuration
x
CON01Ey0H Message Object x Control 0
Register
Address
††
1E3FH Bit Timing 0
1E4FH Bit Timing 1
1E00H Control
1E0AH, 1E0BH
Description
Program this register to define the length of one time quantum
and the maximum number of time quanta by which a bit time can
be modified for resynchronization.
Program this register to define the sample time and mode.
Program this register to prevent transfers to and from the CAN
bus, to enable and disable CAN interrupts, and to control write
access to the bit timing registers.
Extended Global Mask
Program this register to mask (“don’t care”) specific message
identifier bits for extended message objects.
This read-only register indicates the source of the highest-priority
pending interrupt.
Program this register to specify a message object’s data length,
transfer direction, and identifier type.
Program this register to enable or disable the message object’s
successful transmission (TX) and reception (RX) interrupts. Read
this register to determine whether a message object is ready to
transmit and whether an interrupt is pending.
7-3
87C196CB SUPPLEMENT
Table 7-2. Control and Status Registers (Continued)
The CCE bit in CAN_CON must be set to enable write access to the bit timing registers.
††
In register names, x = 1–15; in addresses, y = 1–F.
††
x
DATA0
x
DATA1
x
DATA2
x
DATA3
x
DATA4
x
DATA5
x
DATA6
x
DATA7
x
ID0
x
ID1
x
ID2
x
ID3
Register
1E
1E
1E
1E
1E
1E
1E
1E
1E
1E
1E
1E
††
y7
y
8H
y
9H
y
AH
y
BH
y
CH
y
DH
y
EH
y
2H
y
3H
y
4H
y
5H
Address
1E0EH, 1E0FH
Description
Program this register to indicate that a message is ready to
transmit or to initiate a transmission. Read this register to
determine whether the message object contains new data,
whether a message has been overwritten, whether software is
updating the message, and whether a transfer is pending.
Message Object
H
The data registers contain data to be transmitted or data received.
Do not use unused data bytes as scratch-pad memory; the CAN
controller writes random values to these registers during
operation.
Message Object
Write the message object’s ID to this register. (This register is the
same as the arbitration register of the 82527.)
Message 15 Mask
Program this register to mask (“don’t care”) specific message
identifier bits for message 15 in addition to those bits masked by a
global mask. The message 15 mask is ANDed with the standard
or extended global mask, so any “don’t care” bits defined in a
global mask are also “don’t care” bits for message 15.
Program this register to mask (“don’t care”) specific message
identifier bits for standard message objects.
This register reflects the current status of the CAN contro ller.
The CAN bit in this register enables and disables the CAN
interrupt request.
The CAN bit in this register, when set, indicates a pending CAN
interrupt request.
x
Data 0–7
x
Identification 0–3
7.3CAN CONTROLLER OPERATION
This section describes the address map, message objects, message frames (which contain message objects), error detection and management logic, and bit timing for CAN transmissions and
receptions.
7-4
CAN SERIAL COMMUNICATIONS CONTROLLER
7.3.1Address Map
The CAN controller has 256 bytes of RAM, containing 15 message objects and control and statu s
registers at fixed addresses. Each message object occupies 15 consecutive bytes beginning at a
base address that is a multiple of 16 bytes. The byte above each message object is reserved (indicated by a dash (—) character) or occupied by a control register. The lowest 16 bytes of RAM
contain the remaining control and status registers (Table 7-3). This 256-byte section of memory
can be windowed for register-direct access.
The control register’s CCE bit must be set to enable write access to the bit timing registers .
†
†
†
7.3.2Message Objects
The CAN controller includes 15 message objects, each of which occupies 15 bytes of RAM (Table 7-4). Message objects 1–14 can be configured to either transmit or receive messages, while
message object 15 can only receive messages. Message objects 1–14 have only a single buffer,
so if a second message is received before the CPU reads the first, the first message is overwritten.
Message object 15 has two alternating buffers, so it can receive a second message while the first
is being processed. However, if a third message is received while the CPU is reading the first, the
second message is overwritten.
7-5
87C196CB SUPPLEMENT
Table 7-4. Message Object Structure
Hex Address† Contents
1E
x
7–1ExEData Bytes 0–7
x
6Message Configuration
1E
x
2–1Ex5Message Identifier 0–3
1E
x
0–1Ex1Message Control 0–1
1E
†
x
= message object number, in hexadecimal
7.3.2.1Receive and Transmit Priorities
The lowest-numbered message object always has the highest priority, regardless of the message
identifier. When multiple messages are ready to transmit, the CAN controller transmits the message from the lowest-numbered message object first. When multiple message objects are capable
of receiving the same message, the lowest-numbered message object receives it. For example, if
all identifier bits are masked, message object 1 receives all messages.
7.3.2.2Message Acceptance Filtering
The mask registers provide a method for developing an acceptance filter ing strategy for a specific
system. Software can program the mask registers to require an exact match on specific identifier
bits while masking (“don’t care”) the remaining bits. Withou t a ma sking strategy, a message object could accept only those messages with an identical message identifier. With a masking strategy in place, a message object can accept messages whose identifiers are not identical.
The CAN controller filters messages by comparing an incoming message’s identifier with that of
an enabled internal message object. The standard global mask register applies to messages with
standard (11-bit) identifiers, while the extended glo bal mask register applies to those with extended (29-bit) identifier s. The CAN con troller app lies the approp riate global ma sk to each incom ing
message identifier and checks for an acceptance match in message objects 1–14. If no match exists, it then applies the message 15 mask and checks for a match on message object 15. The message 15 mask is ANDed with the global mask, so any bit that is masked by the global mask is
automatically masked for message 15.
The CAN controller accepts an incoming data message if the message’s identifier matches that
of any enabled receive message object. It accepts an incoming remote message (request for data
transmission) if the message’s identifier matches that of any enabled transmit message object.
The remote message’s identifier is stored in the transmit message object, overwriting any masked
bits. Table 7-5 shows an example.
7-6
CAN SERIAL COMMUNICATIONS CONTROLLER
Table 7-5. Effect of Masking on Message Identifiers
A message object is contained within a message frame that adds control and error-detection bits
to the content of the message object. The frame for an extended message diffe rs slightly from that
for a standard message, but they contain similar information. A data frame contains a message
object with data to be transmitted; a remote frame is a request for another node to transmit a data
frame, so it contains no data.
Figure 7-3 illustrates standard and extended message frames. Table 7-6 and Table 7-7 describe
their contents and summarize the minimum message lengths. Actual message lengths may differ
because the CAN controller adds b its during transmission (see “Er ror Detection and Management
Logic” on page 7-9). After each message fram e, an intermission field consisting of three r ecessive
(1) bits separates messages. This intermission may be followed by a bus idle time.
Standard Frame
Extended Frame
S
11 bit
O
Identifier
F
Arbitration
I
S
D
R
E
R
Control
Field
I
R
r
DLC
D
T
0
E
R
Control
Field
R
r
r
DLC
T
0
1
R
Field
S
O
F
Arbitration
11-bit
Identifier
18-bit
Identifier
Field
Figure 7-3. CAN Message Frames
Data Field
0–8 Bytes
Data Field
0–8 Bytes
CRC
Field
15-bit
CRC
CRC
Field
15-bit
CRC
Ack
F.
Ack
F.
End of
Frame
End of
Frame
A2599-01
7-7
87C196CB SUPPLEMENT
Table 7-6. Standard Message Frame
FieldDescriptionBit Count
SOFStart-of-fr ame. A dominant (0) bit marks the beginning of a message fram e.1
11-bit message identifier.
Arbitration
RTR. Remote transmission request. Dominant (0) for data frames; recessive (1)
for remote frames.
DLC. Data length code. A 4-bit code indicating the number of data bytes (0–8).
DataData. 1 to 8 bytes for data frames; 0 bytes for remote frames.0–64
CRCCRC code. A 15-bit CRC code plus a recessive (1) delimiter bit.16
AckAcknowledgment. A dominant (0) bit sent by nodes receiving the frame plus a
recessive (1) delimiter bit.
End of frame7 recessive (1) b its mark the end of a frame.7
Minimum standard message frame length (bits)44–108
Table 7-7. Extended Message Frame
FieldDescriptionBit Count
SOFStart-of-fr ame. A dominant (0) bit marks the beginning of a message fram e.1
DataData. 1 to 8 bytes for data frames; 0 bytes for remote frames.0–64
CRCCRC code. A 15-bit CRC code plus a recessive (1) delimiter bit.16
AckAcknowledgment. A dominant (0) bit sent by nodes receiving the frame plus a
End of frame7 recessive (1) b its mark the end of a frame. 7
The CAN controller has several error detection mechanisms, including cyclical redundancy
checking (CRC) and bit coding rules (stuffing and destuffing). The CAN controller generates a
CRC code for transmitted messages and checks the CRC code of incoming messages. The CRC
polynomial has been optimized for control applications with short messages.
After five consecutive bits of equal value ar e transmitted, a bit with the opposite polarity is add ed
to the bit stream. This bit is called a stuff bit; by adding a transition, a stuff bit aids in synchronization. All message fields are stuffed except the CRC delimiter, the acknowledgment field, and
the end-of-frame field.
Receiving nodes reject data from any message that is corrupted during transmission and send an
error message via the CAN bus. Transmitting nodes monitor the CAN bus for error messages and
automatically repeat a transmission if an error occurs. The following error types are detected:
• stuff error — more than 5 equal bits in a sequence have occurred in a part of a received
message where this is not allowed
• form error — the fixed-format part of a received frame has the wrong format (for example,
a reserved bit has the wrong value)
• acknowledgment error — this device transmitted a message, but it was not acknowledged
by another node on the CAN bus. (The transmit error counter stops incrementing after 128
acknowledgment errors, so this error type does not cause a bus-off state.)
• bit 1 error — the CAN controller tried to send a recessive (logic 1) bit as part of a
transmitted message (with the exception of the arbitration field), but the monitored CAN
bus value was dominant (logic 0)
• bit 0 error — the CAN controller tried to send a dominant (logic 0) bit as part of a
transmitted message (with the exception of the arbitration field), but the monitored CAN
bus value was recessive (logic 1)
• CRC error — the CRC checksum received for an incoming message does not match the
CRC value that the CAN controller calculated for the received data
The CAN status register indicates the type of the first transmission error that occurred on the
CAN bus and whether an abnormal number of errors have occurr ed. Two counters (a receive err or
counter and a transmit error cou nter) track the number of erro rs. The status register’s warning bit
is set when the receive or transmit error counter reaches 96; the bus-off bit is set when either
counter reaches 256. If this occurs, the CAN controller isolates itself from the CAN bus (floats
the TX pin). Software must clear the INI T bit in th e con trol register (Figure 7-6 on page 7 -13 ) to
begin a bus-off recovery sequence.
7-9
87C196CB SUPPLEMENT
7.3.5Bit Timing
A message object consists of a series of bits transmitted in consecutive bit times. The CAN protocol specifies a bit time composed of four separate, nonoverlapping time segments: a synchronization delay segment, a propagation delay se gment, and two phase delay segments (Figure 7 -4
and Table 7-8). The CAN controller implements a bit time as three segments, combining
PROP_SEG and PHASE_SEG1 into t
(Figure 7-5 and Table 7-9). This implementation is
1
TSEG
identical to that of the 82527 CAN peripheral.
Nominal Bit Time
SYNC_SEG
PROP_SEG
PHASE_SEG1
PHASE_SEG2
SampleTransmit
A2603-01
Figure 7-4. A Bit Time as Specified by the CAN Protocol
Table 7-8. CAN Protocol Bit Time Segments
SymbolDefinition
SYNC_SEGThe synchronization delay segment allows for synchronizat ion of the various nodes on
PROP_SEGThe propagat ion delay segment com pensat es for the phys ical delay times within the
PHASE_SEG1 This segment compensates for edge phase errors. It can be lengthened or shortened by
PHASE_SEG2 This segment compensates for edge phase errors. It can be lengthened or shortened by
the bus. An edge is expected to lie within this segment.
network. It is twice the sum of the signal’s propagation time on the bus line, the input
comparator delay, and the output driver delay. The factor of two accounts for the
requirement that all nodes monitor all bus transmissions for errors.
resynchronization.
resynchronization.
7-10
CAN SERIAL COMMUNICATIONS CONTROLLER
Bit Time
t
SYNC
_SEG
t
TSEG1
t
TSEG2
1 tq
(TSEG1 + 1)tq
(TSEG2 + 1)tq
SampleTransmit
Figure 7-5. A Bit Time as Implemented in the CAN Controller
Table 7-9. CAN Controller Bit Time Segments
SymbolDefinition
t
t
t
This time segment is equivalent to SYNC_SEG in the CAN protocol. Its length is one time
SYNC_SEG
TSEG1
quantum.
This time segment is equivalent to the sum of PROP_SEG and PHASE_SEG 1 in the CAN
protocol. Its length is specified by the TSEG1 field in bit timing register 1. To allow for resynchronization, the sample point can be moved (t
lengthened) by 1 to 4 time quanta, depending on the programmed value of the SJW field in bit
TSEG
or t
1
can be shortened and the other
2
TSEG
timing register 0.
The CAN controller samples the bus once or three times, depending on the value of the
sampling mode (SPL) bit in bit timing register 0. In three-sample mode, the hardware
lengthens t
case, the “sample point” shown in Figure 7-5 is the time of the third sample; the first and
by 2 time quanta to allow time for the additional two bus samples. In this
1
TSEG
second samples occur 2 and 1 time quanta earlier, respectively.
This time segment is equivalent to PHASE_SEG2 in the CAN protocol. Its length is specified
TSEG2
by the TSEG2 field in bit timing register 1. To allow for resynchronization, the sample point
can be moved (t
quanta, depending on the programmed value of the SJW field in bit timing register 0.
TSEG
or t
1
can be shortened and the other lengthened) by 1 to 4 time
2
TSEG
A2602-01
7-11
87C196CB SUPPLEMENT
7.3.5.1Bit Timing Equations
The bit timing equations of the integrated CAN controller are equivalent to those for the 82527
CAN peripheral with the DSC bit in the CPU interface register set (system clock divided by two).
The following equations show the timing calculations for the integrated CAN controller and the
82527 CAN peripheral, respectively.
BRP= the value of the BRP bit in bit timing register 0
TSEG1= the value of the TSEG1 field in bit timing register 0
TSEG2= the value of the TSEG1 field in bit timing register 1
= the input clock frequency on the XTAL1 pin, in MHz
Table 7-10 defines the bit timing relationships of the CAN controller.
Table 7-10. Bit Timing Relationships
Timing
Parameter
t
t
BITTIME
t
XTAL
1
input clock period on XTAL1 (50 ns at 20 MHz operation)
tq2t
t
t
t
t
t
1tq
SYNC_SEG
(TSEG1 + 1) × tq, where TSEG1 is a field in bit timing register 1 (valid values are 2–15)
1
TSEG
(TSEG2 + 1) × tq, where TSEG2 is a field in bit timing register 1 (valid values are 1–7)
2
TSEG
(SJW + 1) × tq, where SJW is a field in bit timing register 0 (valid values are 0–3)
SJW
The portion of t
PROP
the maximum sum of the physical bus delay, input comparator delay, and output driver delay,
+ t
+ t
SYNC_SEG
XTAL
TSEG1
× (BRP + 1), where BRP is a field in bit timing register 0 (valid values are 0–63)
1
TSEG
TSEG2
that is equivalent to PROP_SEG as defined by the CAN protocol. Twice
1
rounded up to the nearest multiple of tq.
Definition
7-12
CAN SERIAL COMMUNICATIONS CONTROLLER
7.4CONFIGURING THE CAN CONTROLLER
This section explains how to configure the CAN controller. Several registers combine to control
the configuration: the CAN control register, the two bit timing registers, and the three mask registers.
7.4.1Programming the CAN Control (CAN_CON) Register
The CAN control register (Figure 7-6) controls write access to the bit timing registers, enables
and disables global interrupt sources (error, status change, and individual message object), and
controls access to the CAN bus.
CAN_CON
(87C196CB)
Program the CAN control (CAN_CON) register to control write access to the bit timing registers, to
enable and disable CAN interrupts, and to control access to the CAN bus.
70
87C196CB
Bit
Number
7—Reserved; for compatibility with future devices, write zero to this bit.
6CCEChange Configuration Enable
5:4—Reserved; for compatibility with future devices, write zeros to these bits.
3EIEError Interrupt Enable
2SIEStatus-ch ange Interrupt Enable
—CCE——EIESIEIEINIT
Bit
Mnemonic
This bit controls whether software can write to the bit timing registers.
0 = prohibit write access
1 = allow write access
This bit enables and disables the bus-off and warn interrupts.
0 = disable bus-off and warn interrupts
1 = enable bus-off and warn interrupts
This bit enables and disables the successful reception (RXOK), successful
transmission (TXOK), and error code change (LEC2:0) interrupts.
When the SIE bit is set, the CAN controller generates a successful
reception (RXOK) interrupt request each time it receives a valid message,
even if no message object accepts it.
Function
Address:
Reset State:
1E00H
01H
Figure 7-6. CAN Control (CAN_CON) Register
7-13
87C196CB SUPPLEMENT
CAN_CON (Continued)
(87C196CB)
Program the CAN control (CAN_CON) register to control write access to the bit timing registers, to
enable and disable CAN interrupts, and to control access to the CAN bus.
70
87C196CB
Bit
Number
1IEInterrupt Enable
0INITSoftware Initialization Enable
—CCE——EIESIEIEINIT
Bit
Mnemonic
This bit globally enables and disables interrupts (error, status-change, and
message object transmit and receive interrupts).
0 = disable interrupts
1 = enable interrupts
When the IE bit is set, an interrupt is generated only if the corresponding
interrupt source’s enable bit (EIE or SIE in CAN_CON; TXIE or RXIE in
CAN_MSG
updates the CAN interrupt pending register, but does not generate an
interrupt.
Setting this bit isolates the CAN bus from the system. (If a transfer is in
progress, it completes, but no additional transfers are allowed.)
A hardware reset sets this bit, enabling you to configure the RAM without
allowing any CAN bus activity. After a hardware reset or software initialization, clearing this bit completes the initialization. The CAN peripheral
waits for a bus idle state (11 consecutive recessive bits) befor e participating in bus activities.
Software can set this bit to stop all receptions and transmissions on the
CAN bus. (To prevent transmission of a specific message object while its
contents are being updated, set the CPUUPD bit in the individual message
object’s control register 1. See “Configuring Message Objects” on page
7-20.)
Entering powerdown mode stops an in-progress CAN transmission
immediately. To avoid stopping a CAN transmission while it is sending a
dominant bit on the CAN bus, set the INIT bit before executing the IDLPD
instruction.
The CAN peripheral also sets this bit to isolate the CAN bus when an error
counter reaches 256. This isolation is called a
bus-off condition, clearing this bit initiates a bus-off recovery sequence,
which clears the error counters. The CAN peripheral waits for 128 bus idle
states (128 packets of 11 consecutive recessive bits), then resumes
normal operation. (See “Bus-off State” on page 7-41.)
x
_CON0) is also set. If the IE bit is clear, an interrupt request
Function
Address:
Reset State:
bus-off
condition. After a
1E00H
01H
7-14
Figure 7-6. CAN Control (CAN_CON) Register (Continued)
CAN SERIAL COMMUNICATIONS CONTROLLER
7.4.2Programming the Bit Timing 0 (CAN_BTIME0) Register
Bit timing register 0 (Figure 7-7) defines the length of one time quantum and the maximum
amount by which the sample point can be moved (t
TSEG1
or t
can be shortened and the other
TSEG2
lengthened) to compensate for resynchronization.
CAN_BTIME0
(87C196CB)
†
Address:
Reset State:
1E3FH
Unchanged
Program the CAN bit timing 0 (CAN_BTIME0) register to define the length of one time quantum and
the maximum number of time quanta by which a bit time can be modified for resynchronization.
70
87C196CB
Bit
Number
SJW1SJW0BRP5BRP4BRP3BRP2BRP1BRP0
Bit
Mnemonic
Function
7:6SJW1:0Synchronization Jump Width
This field defines the maximum number of time quanta by which a resynchronization can modify t
3. The hardware adds 1 to the programmed value, so a “1” value causes
TSEG1
and t
. Valid programmed values are 0–
TSEG2
the CAN peripheral to add or subtract 2 time quanta, for example. This
adjustment has no effect on the total bit time; if t
t
is decreased by 2 tq, and vice versa.
TSEG2
is increased by 2 tq,
TSEG1
5:0BRP5:0Baud-rate Prescaler
This field defines the length of one time quantum (tq), using the following
formula, where t
values are 0–63.
tq2t
XTAL1
is the input clock period on XTAL1. Valid programmed
XTAL1
BRP 1+()×=
For example, at 20 MHz operation, the system clock period is 50 ns.
Writing 3 to BRP achieves a time quanta of 400 ns; writing 1 to BRP
achieves a time quanta of 200 ns.
tq2 50×()31+()×400 ns==
tq2 50×()11+()×200 ns==
†
The CCE bit (CAN_CON.6) must be set to enable write access to this register.
Figure 7-7. CAN Bit Timing 0 (CAN_BTIME0) Register
7-15
87C196CB SUPPLEMENT
7.4.3Programming the Bit Timing 1 (CAN_BTIME1) Register
Bit timing register 1 (Figure 7-8) controls the time at which the bus is sampled and the number
of samples taken. In single-sample mode, the bus is sampled once and the value of that sample is
considered valid. In three-sample mode, the bus is sampled three times and the value of the majority of those samples is considered valid. Single-sample mode may achieve a faster transmission rate, but it is more susceptible to errors caused by noise on the CAN bus. Three-sample mode
is less susceptible to noise-related errors, but it may be slower. If you specify three-sample mode,
the hardware adds two time quanta to the TSEG1 value to allow time for two additional samples
during t
TSEG1
.
CAN_BTIME1
(87C196CB)
†
Address:
Reset State:
1E4FH
Unchanged
Program the CAN bit timing 1 (CAN_BTIME1) register to define the sample time and the sample
mode. The CAN controller samples the bus during the last one (in single-sample mode) or three (in
three-sample mode) time quanta of t
Therefore, specifying the lengths of t
mission point.
, and initiates a transmission at the end of t
TSEG1
TSEG1
and t
defines both the sample point and the trans-
TSEG2
TSEG2
.
70
87C196CB
Bit
Number
SPLTSEG2TSEG1
Bit
Mnemonic
Function
7SPLSampling Mode
This bit determines how many samples are taken to determine a valid bit
value.
0 = 1 sample
1 = 3 samples, using majority logic
6:4TSEG2
††
Time Segment 2
This field determines the length of time that follows the sample point within
a bit time. Valid programmed values are 1–7; the hardware adds 1 to this
value.
3:0TSEG1
††
Time Segment 1
This field defines the length of time that precedes the sample point within a
bit time. Valid programmed values are 2–15; the hardware adds 1 to this
value. In three-sample mode, the hardware adds 2 time quanta to allow
time for the two additional samples.
†
The CCE bit (CAN_CON.6) must be set to enable write access to this register.
††
For correct operation according to the CAN protocol, the total bit time must be at least 8 time
quanta, so the sum of the programmed values of TSEG1 and TSEG2 m ust be at lea st 5. (The
total bit time is the sum of t
and the hardware adds 1 to both TSEG1 and TSEG2. Therefore, if TSEG1 + TSEG2 = 5, the
SYNC_SEG
+ t
TSEG1
+ t
TSEG2
. The length of t
SYNC_SEG
is 1 time quanta,
total bit length will be equal to 8 (1+5+1+1)). Table 7-11 lists additional conditions that must be
met to maintain synchronization.
7-16
Figure 7-8. CAN Bit Timing 1 (CAN_BTIME1) Register
CAN SERIAL COMMUNICATIONS CONTROLLER
Table 7-11. Bit Timing Requirements for Synchronization
Bit Time
Segment
t
TSEG1
t
TSEG2
RequirementComments
≥ 3tqminimum tolerance with 1tq propagation delay allowance
≥ t
+ t
SJW
≥ t
SJW
≥ 2tqminimum tolerance
≥ t
SJW
for single-sample mode
PROP
+ t
+ 2tq for three-sample mode
PROP
if t
> t
SJW
, sampling may occur after the bit time
TSEG2
7.4.4Programming a Message Acceptance Filter
The mask registers provide a method for developing an acceptance filtering strategy. Without a
filtering strategy, a message object could accept an incoming message only if their identifiers
were identical. The mask registers allow a message object to ignore one or more bits of incoming
message identifiers, so it can accept a range of message identifiers.
The standard global mask register (Figure 7-9) applies to messages with standard (11-bit) message identifiers, while the extended global mask register (Figure 7-10) applies to messages with
extended (29-bit) identifiers. The message 15 mask register (Figure 7-11) provides an additional
filter for message object 15, to allow it to accept a greater range of message identifiers than message objects 1–14 can. Clear a mask bit to accept either a zero or a one in that position.
The CAN controller app lies th e approp riate global mask to each incom ing message id entifier and
checks for an acceptance match on message objects 1–14. If no match exists, it then applies the
message 15 mask and checks for a match on message object 15.
7-17
87C196CB SUPPLEMENT
CAN_SGMSK
(87C196CB)
Program the CAN standard global mask (CAN_SGMSK) register to mask (“don’t care”) specific
message identifier bits for standard message objects.
158
87C196CB
Bit
Number
15:13MSK20:18ID Mask
12:8—Reserved; for compatibility with future devices, write zeros to these bits.
7:0MSK28:21ID Mask
MSK20MSK19MSK18—————
70
MSK28MSK27MSK26MSK25MSK24MSK23MSK22MSK21
Bit
Mnemonic
These bits individually mask incoming message identifier (ID) bits.
0 = mask the ID bit (accept either “0” or “1”)
1 = accept only an exact match
These bits individually mask incoming message identifier (ID) bits.
0 = mask the ID bit (accept either “0” or “1”)
1 = accept only an exact match
Address:
Reset State:
Function
1E07H, 1E06H
Unchanged
Figure 7-9. CAN Standard Global Mask (CAN_SGMSK) Register
7-18
CAN SERIAL COMMUNICATIONS CONTROLLER
CAN_EGMSK
(87C196CB)
Program the CAN extended global mask (CAN_EGMSK) register to mask (“don’t care”) specific
message identifier bits for extended message objects.
3124
87C196CB
Bit
Number
31:27MSK4:0ID Mask
26:24—Reserved; for compatibility with future devices, write zeros to these bits.
23:16
15:8
7:0
MSK4MSK3MSK2MSK1MSK0———
2316
MSK12MSK11MSK10MSK9MSK8MSK7MSK6MSK5
158
MSK20MSK19MSK18MSK17MSK16MSK15MSK14MSK13
70
MSK28MSK27MSK26MSK25MSK24MSK23MSK22MSK21
Bit
Mnemonic
These bits individually mask incoming message identifier (ID) bits.
0 = mask the ID bit (accept either “0” or “1”)
1 = accept only an exact match
MSK12:5
MSK20:13
MSK28:21
ID Mask
These bits individually mask incoming message identifier (ID) bits.
0 = mask the ID bit (accept either “0” or “1”)
1 = accept only an exact match
Address:
Reset State:
Function
1E0BH, 1E0AH,
1E09H, 1E08H
Unchanged
Figure 7-10. CAN Extended Global Mask (CAN_EGMSK) Register
7-19
87C196CB SUPPLEMENT
CAN_MSK15
(87C196CB)
Program the CAN message 15 mask (CAN_MSK15) register to mask (“don’t care”) specific mess age
identifier bits for message 15 in addition to those bits masked by a global mask (CAN_EGMSK or
CAN_SGMSK).
87C196CB
Bit
Number
31:27MSK4:0ID Mask
26:24—Reserved. These bits are undefined; for com patibility with f uture devices ,
23:16
15:8
7:0
†
Setting a CAN_MSK15 bit in any position that is cleared in the global mask register has no effect.
The message 15 mask is ANDed with the global mask, so any “don’t care” bits defined in a global
mask are also “don’t care” bits for message 15.
†
3124
MSK4MSK3MSK2MSK1MSK0———
2316
MSK12MSK11MSK10MSK9MSK8MSK7MSK6MSK5
158
MSK20MSK19MSK18MSK17MSK16MSK15MSK14MSK13
70
MSK28MSK27MSK26MSK25MSK24MSK23MSK22MSK21
These bits individually mask incoming message identifier (ID) bits.
0 = mask the ID bit (accept either “0” or “1”)
1 = accept only an exact match
do not modify these bits.
MSK12:5
MSK20:13
MSK28:21
ID Mask
These bits individually mask incoming message identifier (ID) bits.
0 = mask the ID bit (accept either “0” or “1”)
1 = accept only an exact match
Function
Address:
Reset State:
1E0FH, 1E0EH,
1E0DH, 1E0CH
Unchanged
Figure 7-11. CAN Message 15 Mask (CAN_MSK15) Register
7.5CONFIGURING MESSAGE OBJECTS
Each message object consists of a configuration register, a message identifier, control registers,
and data registers (from zero to eight bytes of data). This section explains how to configur e message objects and determine their status.
7-20
CAN SERIAL COMMUNICATIONS CONTROLLER
7.5.1Specifying a Message Object’s Configuration
Each message object configuration register (Figure 7-12) specifies a message identifier type
(standard or extended), transfer direction (transmit or receive), and data length (in bytes).
CAN_MSGxCFG
x
= 1–15 (87C196CB)
Program the CAN message object
object’s data length, transfer direction, and identifier type.
70
87C196CB
Bit
Number
7:4DLC3:0Data Length Code
3DIRDirection
2XTDExtended Identifier Used
1:0—Reserved; for compatibility with future devices, write zeros to these bits.
DLC3DLC2DLC1DLC0DIRXTD——
Bit
Mnemonic
x
configuration (CAN_MSGxCFG) register to specify a message
Specify the number of data bytes this message object contains. Valid
values are 0–8. The CAN controller updates a receive message object’s
data length code after each reception to reflect the number of data bytes in
the current message.
Specify whether this message object is to be transmitted or is to receive a
message object from a remote node.
0 = receive
1 = transmit
Specify whether this message object’s identification registers contain an
extended (29-bit) or a standard (11-bit) identifier.
0 = standard identifier
1 = extended identifier
Address:
Reset State:
Function
1E
x
6H (x = 1–F)
Unchanged
Figure 7-12. CAN Message Object x Configuration (CAN_MSGxCFG) Register
Set the XTD bit for a message object with an extended identifier; clear it for a message with a
standard identifier. If you accidentally clear the XTD bit for a m essage that has an extend ed identifier, the CAN controller will clear the extended bits in the identification register. If you set the
XTD bit for a message object, that message object cannot receive message objects with stand ard
identifiers.
For a transmit message, set the DIR bit and write the number of prog rammed data bytes (0–8) to
the DLC field. For a receive message, clear the DIR bit. The CAN controller stor es the data length
from the received message in the DLC field.
7-21
87C196CB SUPPLEMENT
7.5.2Programming the Message Object Identifier
Each message identifier register (Figure 7-13) specifies the message’s identifier. For messages
with extended identifiers, write the identifier to bits ID28:0. For messages with standard identifiers, write the identifier to bits ID28:18. Software can chang e the identifier during normal operation without requiring a subsequent device reset. Clear the MSGVAL bit in the corresponding
message control register 0 to prevent the CAN co ntroller from accessing the message object while
the modification takes place, then set the bit to allow access.
CAN_MSGxID0–3
x
= 1–15 (87C196CB)
Write the message object’s identifier to the CAN message object
register. Software can change the identifier during normal operation. Clear the MSGVAL bit in the
corresponding CAN_MSG
change the identifier in CAN_MSG
87C196CB3124
CAN_MSG
CAN_MSG
CAN_MSG
CAN_MSG
Bit
Number
31:27
23:16
12:8
26:24—Reserved; for compatibility with future devices, write zeros to these bits.
15:13
7:0
†
This register is the same as the arbitration register in the standalone 82527 CAN peripheral.
†
x
CON0 register to prevent the CPU from accessing the message object,
x
ID0–3, then set the MSGVAL bit to allow access.
x
ID3ID4ID3ID2ID1ID0———
2316
x
ID2ID12ID11ID10ID9ID 8ID7ID6ID5
158
x
ID1ID20ID19ID18ID17ID16ID15ID14ID13
70
x
ID0ID28ID27ID26ID25ID24ID23ID22ID21
Bit
Mnemonic
ID4:0
ID12:5
ID17:13
ID20:18
ID28:21
Message Identifier 17:0
These bits hold the 18 least-significant bits of an extended identifier. If
you write an extended identifier to these bits, but specify a standard
identifier (XTD = 0) in the corresponding message object’s configuration
register (CAN_MSG
Message Identifier 28:18
These bits hold either an entire standard identifier or the 11 most-
significant bits of an extended identifier.
x
CFG), the CPU clears these bits (ID17:0).
Address:
Reset State:
x
identifier (CAN_MSGxID0–3)
Function
1E
1E
(
x
Unchanged
x
5H, 1Ex4H,
x
3H, 1Ex2H
= 1–F)
7-22
Figure 7-13. CAN Message Object x Identifier (CAN_MSGxID0–3) Register
CAN SERIAL COMMUNICATIONS CONTROLLER
7.5.3Programming the Message Object Control Registers
Each message object control register consists of four bit pairs — one bit of each pair is in true
form and one is in complement form. This format allows software to set or clear any bit with a
single write operation, without affecting the remaining bits. Table 7-12 shows how to interpret
the bit-pair values.
Table 7-12. Control Register Bit-pair Interpretation
Message object control register 0 (Figure 7-14 ) indicates whether an interrupt is pending, contro ls
whether a successful transmission or reception generates an interrupt, and indicates whether a
message object is ready to transmit.
7.5.3.2Message Object Control Register 1
Message object control register 1 (Figure 7-15) indicates whether the message object contains
new data, whether a message has been overwritten, whether the message is being updated, and
whether a transmission or reception is pending. Message objects 1–14 have only a single buffer,
so if a second message is received before the CPU reads the first, the first message is overwritten.
Message object 15 has two alternating buffers, so it can receive a second message while the first
is being processed. However, if a third message is received while the CPU is reading the first, the
second message is overwritten.
7.5.4Programming the Message Object Data
Each message object can have from zero to eight bytes of data. For transmit message objects,
write the message data to the data registers (Figure 7-16). For receiv e message objects, the CAN
controller stores the received data in these registers. The CAN controller writes random value s to
any unused data bytes during operation, so you should not use unused data bytes as scratch-pad
memory.
7-23
87C196CB SUPPLEMENT
CAN_MSGxCON0
x
= 1–15 (87C196CB)
x
Program the CAN message object
message object is ready to transmit and to control whether a successful transmiss ion or reception
generates an interrupt. The least-significant bit-pair indicates whether an interrupt is pending.
This register consists of four bit-pairs — the most-significant bit of each pair is in true form and the
least-significant bit is in complement form. This format allows softwar e to set or clear any bit with a
single write operation, without affecting the remaining bits.
70
87C196CB
Bit
Number
7:6MSGVALMessage Object Valid
5:4TXIETransmit Interrupt Enable
MSGVAL MSGVALTXIETXIERXIERXIEINT_PND INT_PND
Bit
Mnemonic
Set this bit-pair to indicate that a message object is valid (configured and
ready for transmission or reception).
bit 7 bit 6
01not ready
10message object is valid
The CAN peripheral will access a message object only if this bit-pair
indicates that the message is valid. If multiple message objects have the
same identifier, only one can be valid at any given time.
During initialization, software should clear this bit for any unused message
objects. Software can clear this bit if a message is no longer needed or if
you need to change a message object’s contents or identifier.
Receive message objects do not use this bit-pair.
For transmit message objects, set this bit-pair to enable the CAN
peripheral to initiate a transmit (TX) interrupt after a successful transmission. You must also set the interrupt enable bit (CAN_CON.1) to enable
the interrupt.
bit 5 bit 4
01no interru pt
10generate an interrupt
control 0 (CAN_MSGxCON0) register to indicate whether the
Address:
Reset State:
Function
1E
x
0H (x = 1–F)
Unchanged
7-24
Figure 7-14. CAN Message Object x Control 0 (CAN_MSGxCON0) Register
CAN SERIAL COMMUNICATIONS CONTROLLER
CAN_MSG
x
= 1–15 (87C196CB)
Program the CAN message object
message object is ready to transmit and to control whether a successful transmiss ion or reception
generates an interrupt. The least-significant bit-pair indicates whether an interrupt is pending.
This register consists of four bit-pairs — the most-significant bit of each pair is in true form and the
least-significant bit is in complement form. This format allows softwar e to set or clear any bit with a
single write operation, without affecting the remaining bits.
87C196CB
Number
3:2RXIEReceive Interrupt Enable
1:0INT_PNDInterrupt Pending
Bit
x
CON0 (Continued)
x
control 0 (CAN_MSGxCON0) register to indicate whether the
70
MSGVAL MSGVALTXIETXIERXIERXIEINT_PND INT_PND
Bit
Mnemonic
Transmit message objects do not use this bit-pair.
For a receive message object, set this bit-pair to enable this message
object to initiate a receive (RX) interrupt after a successful reception. You
must also set the interrupt enable bit (CAN_CON.1) to enable the interrupt.
bit 3 bit 2
01no interru pt
10generate an interrupt
This bit-pair indicates that this message object has initiated a transmit (TX)
or receive (RX) interrupt. Software must clear this bit when it services the
interrupt.
bit 1 bit 0
01no interru pt
10an interru pt was generat ed
Address:
Reset State:
Function
1E
x
0H (x = 1–F)
Unchanged
Figure 7-14. CAN Message Object x Control 0 (CAN_MSGxCON0) Register (Continued)
7-25
87C196CB SUPPLEMENT
CAN_MSGxCON1
x
= 1–15 (87C196CB)
The CAN message object
Address:
Reset State:
x
control 1 (CAN_MSGxCON1) register indicates whether a message
1E
x
1H (x = 1–F)
Unchanged
object has been updated, whether a message has been overwritten, whether the CPU is updating the
message, and whether a transmission or reception is pending.
This register consists of four bit-pairs — the most-significant bit of each pair is in true form and the
least-significant bit is in complement form. This format allows software to set or clear any bit with a
single write operation, without affecting the remaining bits.
70
87C196CB
Bit
Number
RMTPND RMTPND TX_REQTX_REQ
Bit
Mnemonic
MSGLST
CPUUPD
Function
MSGLST
CPUUPD
NEWDAT NEWDAT
7:6RMTPN DRemote Request Pending
Receive message objects do not use this bit-pair.
The CAN controller sets this bit-pair to indicate that a remote frame has
requested the transmission of a transmit message object. If the CPUUPD
bit-pair is clear, the CAN controller transmits the message object, then
clears RMTPND. Setting RMTPND does not cause a transmission; it only
indicates that a transmission is pending.
bit 7 bit 6
01no pending request
10a remote request is pending
5:4TX_RE QT ransm ission Request
Set this bit-pair to cause a receive message object to transmit a remote
frame (a request for transmission) or to cause a transmit object to transmit
a data frame. Read this bit-pair to determine whether a transmission is in
progress.
bit 5 bit 4
01no pending request; no transmission in progress
10transm ission request ; transmission in progress
7-26
Figure 7-15. CAN Message Object x Control 1 (CAN_MSGxCON1) Register
CAN SERIAL COMMUNICATIONS CONTROLLER
CAN_MSG
x
= 1–15 (87C196CB)
x
CON1 (Continued)
The CAN message object
x
control 1 (CAN_MSGxCON1) register indicates whether a message
Address:
Reset State:
1E
x
1H (x = 1–F)
Unchanged
object has been updated, whether a message has been overwritten, whether the CPU is updating the
message, and whether a transmission or reception is pending.
This register consists of four bit-pairs — the most-significant bit of each pair is in true form and the
least-significant bit is in complement form. This format allows software to set or clear any bit with a
single write operation, without affecting the remaining bits.
70
87C196CB
Bit
Number
RMTPND RMTPND TX_REQTX_REQ
Bit
Mnemonic
3:2MSGLST or
CPUUPD
MSGLST
CPUUPD
Function
Message Lost (Receive)
For a receive message object, the CAN controller sets this bit-pair to
MSGLST
CPUUPD
NEWDAT NEWDAT
indicate that it stored a new message while the NEWDAT bit-pair was still
set, overwriting the previous message.
bit 3 bit 2
01no overwrite occurr ed
10a message was lost (overwritt en)
CPU Updating (Transmit)
For a transmit message object, software should set this bit-pair to indicate
that it is in the process of updating the message contents. This prevents a
remote frame from triggering a transmission that would contain invalid
data.
bit 3 bit 2
01the message is valid
10software is updating data
1:0NEWDA TNew Data
This bit-pair indicates whether a message object is valid (configured and
ready for transmission).
bit 1 bit 2
01not ready
10message object is valid
For receive message objects, the CAN peripheral sets this bit-pair when it
stores new data into the message object.
For transmit message objects, set this bit-pair and clear the CPUUPD bitpair to indicate that the message contents have been updated. Clearing
CPUUPD prevents a remote frame from triggering a transmission that
would contain invalid data.
During initialization, clear this bit for any unused message objects.
Figure 7-15. CAN Message Object x Control 1 (CAN_MSGxCON1) Register (Continued)
7-27
87C196CB SUPPLEMENT
CAN_MSGxDATA0–7
x
= 1–15 (87C196CB)
The CAN message object data (CAN_MSG
received. Any unused data bytes have random values that change during operation.
87C196CB70
x
CAN_MSG
CAN_MSG
CAN_MSG
CAN_MSG
CAN_MSG
CAN_MSG
CAN_MSG
CAN_MSG
DATA7Data 7
70
x
DATA6Data 6
70
x
DATA5Data 5
70
x
DATA4Data 4
70
x
DATA3Data 3
70
x
DATA2Data 2
70
x
DATA1Data 1
70
x
DATA0Data 0
x
DATA0–7) registers contain data to be transmitted or data
Address:
Reset State:
1E
x
EH, 1ExDH,
1E
x
CH, 1ExBH,
1E
x
AH, 1Ex9H,
1E
x
8H, 1Ex7H
(
x
= 1–F)
Unchanged
Bit
Number
7:0Data
Figure 7-16. CAN Message Object Data (CAN_MSGxDATA0–7) Registers
7-28
Function
Each message object can use from zero to eight data registers to hold data to
be transmitted or data received.
For receive message objects, these registers accept data during a reception.
For transmit message objects, write the data that is to be transmitted to these
registers. The number of data bytes must match the DLC field in the
CAN_MSG
CAN_MSG1DATA1, CAN_MSG1DATA2, and CAN_MSG1DATA3 contain data,
the DLC field in CAN_MSG1CFG must contain 04H.)
x
CFG register. (For example, if CAN_MSG 1DAT A 0,
CAN SERIAL COMMUNICATIONS CONTROLLER
7.6ENABLING THE CAN INTERRUPTS
The CAN controller has a single interrupt input (INT13) to the interrupt controller. (Generally,
PTS interrupt service is not useful for the CAN controller because the PTS cannot readily determine the source of the CAN controller’s mu ltiplexed interr upts.) To enab le the CAN co ntroller’s
interrupts, you must enable the interrupt source by setting the CAN bit in INT_MASK1 (see Table 7-2 on page 7-3) and globally enable interrupt servicing (by executing the EI instruction). In
addition, you must set bits in the CAN control register (Figure 7-17) and the individual message
objects’ control register 0 (Figu re 7-18) to enable th e individual interrup t sources within the CAN
controller.
CAN_CON
(87C196CB)
Program the CAN control (CAN_CON) register to control write access to the bit timing registers, to
enable and disable CAN interrupts, and to control access to the CAN bus.
70
87C196CB
Bit
Number
7—Reserved; for compatibility with future devices, write zero to this bit.
6CCEChange Configuration Enable
5:4—Reserved; for compatibility with future devices, write zeros to these bits.
3EIEError Interrupt Enable
2SIEStatus-ch ange Interrupt Enable
—CCE——EIESIEIEINIT
Bit
Mnemonic
This bit enables and disables the bus-off and warn interrupts.
0 = disable bus-off and warn interrupts
1 = enable bus-off and warn interrupts
This bit enables and disables the successful reception (RXOK), successful
transmission (TXOK), and error code change (LEC2:0) interrupts.
When the SIE bit is set, the CAN controller generates a successful
reception (RXOK) interrupt request each time it receives a valid message,
even if no message object accepts it.
Function
Address:
Reset State:
1E00H
01H
Figure 7-17. CAN Control (CAN_CON) Register
7-29
87C196CB SUPPLEMENT
CAN_CON (Continued)
(87C196CB)
Program the CAN control (CAN_CON) register to control write access to the bit timing registers, to
enable and disable CAN interrupts, and to control access to the CAN bus.
70
87C196CB
Bit
Number
1IEInterrupt Enable
0INITSoftware Initialization Enable
—CCE——EIESIEIEINIT
Bit
Mnemonic
This bit globally enables and disables interrupts (error, status-change, and
message object transmit and receive interrupts).
0 = disable interrupts
1 = enable interrupts
When the IE bit is set, an interrupt is generated only if the corresponding
interrupt source’s enable bit (EIE or SIE in CAN_CON; TXIE or RXIE in
CAN_MSG
updates the CAN interrupt pending register, but does not generate an
interrupt.
x
_CON0) is also set. If the IE bit is clear, an interrupt request
Function
Address:
Reset State:
1E00H
Figure 7-17. CAN Control (CAN_CON) Register (Continued)
01H
7-30
CAN SERIAL COMMUNICATIONS CONTROLLER
CAN_MSGxCON0
x
= 1–15 (87C196CB)
x
Program the CAN message object
message object is ready to transmit and to control whether a successful transmiss ion or reception
generates an interrupt. The least-significant bit-pair indicates whether an interrupt is pending.
This register consists of four bit-pairs — the most-significant bit of each pair is in true form and the
least-significant bit is in complement form. This format allows softwar e to set or clear any bit with a
single write operation, without affecting the remaining bits.
Receive message objects do not use this bit-pair.
For transmit message objects, set this bit-pair to enable the CAN
peripheral to initiate a transmit (TX) interrupt after a successful transmission. You must also set the interrupt enable bit (CAN_CON.1) to enable
the interrupt.
bit 5 bit 4
01no interru pt
10generate an interrupt
Transmit message objects do not use this bit-pair.
For receive message objects, set this bit-pair to enable the CAN peripheral
to initiate a receive (RX) interrupt after a successful reception. You must
also set the interrupt enable bit (CAN_CON.1) to enable the interrupt.
bit 3 bit 2
01no interru pt
10generate an interrupt
control 0 (CAN_MSGxCON0) register to indicate whether the
Address:
Reset State:
Function
1E
x
0H (x = 1–F)
Unchanged
Figure 7-18. CAN Message Object x Control 0 (CAN_MSGxCON0) Register
When the SIE bit in the CAN control register is set, the CAN controller generates a successful
reception (RXOK) interrupt request each time it receives a valid message, even if no message object accepts it. If you set both the SIE bit (Figure 7-17) and an individual message object’s RXIE
bit (Figure 7-18), the CAN controller gen erates two interrupt requests each time a message object
receives a message. The status change interrupt is useful during developmen t to detect bu s error s
caused by noise or other hardware problems. However, you should disable this interrupt during
normal operation in most applications. If the status change interrupt is enabled, each status
change generates an interrupt request, placing an unnecessary burden on the CPU. To prevent redundant interrupt req uests, enable the er ror interrupt sou rces (with th e EIE bit) and enab le the receive and transmit interrupts in the individual message objects.
7-31
87C196CB SUPPLEMENT
7.7DETERMINING THE CAN CONTROLLER’S INTERRUPT STATUS
A successful reception or transmission or a change in the status register can cause the CAN controller to generate an interrupt r equest. Th e INT_PEND1 r egister (see Table 7 -2 on p age 7 -3) indicates whether a CAN interrupt request is pending. The CAN interrupt pending reg i ster (Fig ure
7-19) indicates the source of the request (either the status register or a specific message object).
Your interrupt service routine should read the CAN_INT register to ensure that no additional interrupts are pending before executing the return instruction.
CAN_INT
read-only (87C196CB)
The CAN interrupt pending (CAN_INT) register indicates the source of the highest priority pending
interrupt. If a status change generated the interrupt request, software can read the status register
(CAN_STAT) to determine whether the interrupt request was caused by an abnormal error rate, a
successful reception, a successful transmis sion, or a new error. If an individual message object
generated the interrupt request, software can read the associated message object control 0 register
(CAN_MSG
request is pending.
87C196CB
Number
7:0Pending Interrupt
Bit
x
CON0). The INT_PND bit-pair will be set, indicating that a receive or transmit interrupt
70
Pending Interrupt
Function
This field indicates the source of the highest priority pending interrupt.
ValuePen di ng Interru p tPriori ty (15 is hi ghest; 0 is low est)
Figure 7-19. CAN Interrupt Pending (CAN_INT) Register
If a status change generated the interrupt (CAN_INT = 01H), software can read the CAN status
register (Figure 7-20) to determine the source of the interrupt request.
7-32
CAN SERIAL COMMUNICATIONS CONTROLLER
CAN_STAT
(87C196CB)
The CAN status (CAN_STAT) register reflects the current stat us of the CAN peripheral.
70
87C196CB
Bit
Number
7BUSOFFBus-off Status
6WARNWarning Status
5—Reserved. This bit is undefined.
4RXOKReception Successful
3TXOKTransmission Successful
2:0LEC2:0Last Error Code
BUSOFFWARN—RXOKTXOKLEC2LEC1LEC0
Bit
Mnemonic
The CAN peripheral sets this read-only bit to indicate that it has isolated
itself from the CAN bus (floated the TX pin) because an error counter has
reached 256. A bus-off recovery sequence clears this bit and clears the
error counters. (See “Bus-off State” on page 7-41.)
The CAN peripheral sets this read-only bit to indicate that an error counter
has reached 96, indicating an abnormal rate of errors on the CAN bus.
The CAN peripheral sets this bit to indicate that a message has been
successfully received (error free, regardless of acknowledgment) since the
bit was last cleared. Software must clear this bit when it services the
interrupt.
The CAN peripheral sets this bit to indicate that a message has been
successfully transmitted (error free and acknowledged by at least one
other node) since the bit was last cleared. Software must clear this bit
when it services the interrupt.
This field indicates the error type of the first error that occurs in a message
frame on the CAN bus. (“Error Detection and Management Logic” on page
7-9 describes the error types.)
If an individual message object caused the interrupt request (CAN_INT = 02–10H), software can
read the associated message object control 0 register (Figure 7-21). The INT_PND bit-pair will
be set, indicating that a receive or transmit interrupt request is pending
7-33
87C196CB SUPPLEMENT
.
CAN_MSGxCON0
(
n
= 1–15)
Program the CAN message object
Address:1E
Reset State:Unchanged
x
control 0 register (CAN_MSGxCON0) to indicate whether the
x
0H (x=1–F)
message object is ready to transmit and to control whether a successful transmission or reception
generates an interrupt. The most-significant bit-pair indicates whether an interrupt is pending.
This register consists of four bit-pairs — the most-significant bit of each pair is in true form and the
least-significant bit is in complement form. This format allows software to set or clear any bit with a
single write operation, without affecting the remaining bits.
This bit-pair indicates that the CAN peripheral has initiated a transmit (TX)
or receive (RX) interrupt. Software must clear this bit when it services the
interrupt.
01 = no interrupt
10 = an interrupt was generated
Figure 7-21. CAN Message Object x Control 0 (CAN_MSGxCON0) Register
7-34
CAN SERIAL COMMUNICATIONS CONTROLLER
7.8FLOW DIAGRAMS
The flow diagrams in this section describe the steps that your software (shown as CPU) and the
CAN controller execute to receive and transmit messages. Table 7-13 lists the reg ister bits shown
in the diagrams along with their associated registers and a cross-reference to the figure that describes them.
Table 7-13. Cross-reference for Register Bits Shown in Flowcharts