![](http://datasheet.mmic.net.cn/110000/M32186F8VFP_datasheet_3496152/M32186F8VFP_728.png)
13
CAN MODULE
13-118
32185/32186 Group Hardware Manual
Rev.1.10 REJ09B0235-0110 May 15, 07
13.4 Initializing CAN Module
13.4.1 Initializing CAN Module
Before performing communication, set up the CAN module as described below.
(1) Selecting pin functions
The CAN transmit data output pin (CTX) and CAN receive data input pin (CRX) are shared with input/output
ports. Be sure to select the functions of these pins. (See Chapter 8, “Input/Output Ports and Pin Functions.”
(2) Setting the Interrupt Controller (ICU)
To use CAN module interrupts, set their interrupt priority levels.
(3) Setting CAN Error, CAN Single-Shot and CAN Slot Interrupt Request Mask Registers
To use CAN bus error, CAN error passive, CAN error bus off, CAN single-shot or CAN slot interrupts, set
each corresponding bit to "1" to enable the interrupt request.
(4) Setting DMAC
To use DMA transfers by CAN, be sure to set the DMAC.
(5) Setting CAN DMA transfer request select register
To use DMA transfers by CAN, set the CAN DMA transfer request select register to choose the cause of
transfer request.
(6) Setting CAN module clock
Set clock supplied for protocol engine block of CAN module.
After confirmation for the status of reset CAN module, select CPUCLK/4 in CANx Clock.
(7) Setting the bit timing and the number of times sampled
Using the CAN Configuration Register and CAN Baud Rate Prescaler, set the bit timing and the number of
times the CAN bus is sampled.
1) Setting the bit timing
Determine the period Tq that is the base of bit timing, the configuration of Propagation Segment, Phase
Segment1 and Phase Segment2, and reSynchronization Jump Width. The equation to calculate Tq is
given below.
Tq period = (BRP + 1) / (CPUCLK/4)
The baud rate is determined by the number of Tq’s that comprise one bit. The equation to calculate the
baud rate is given below.
Baud rate (bps) =
1
Tq period
× number of Tq in one bit
Number of Tq’s in one bit = Synchronization Segment + Propagation Segment + Phase Segment 1
+ Phase Segment 2
Note: The maximum baud rate for communication depends on the system configuration (e.g.,
bus length, clock error, CAN bus transceiver, sampling position and bit configuration).
Consider the system configuration when setting the baud rate and number of Tq.