Initializing The Can Module - Renesas M32R/ECU Series User Manual

Mitsubishi 32-bit risc single-chip microcomputers
Table of Contents

Advertisement

13

13.4 Initializing the CAN Module

13.4.1 Initializing the 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 data receive 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 the CAN Error, CAN Single-Shot and CAN Slot Interrupt Request Enable 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 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 = (BRP + 1) / (CPU clock/2)
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) =
Number of Tq's in one bit = Synchronization Segment + Propagation Segment + Phase Segment 1
2) Setting the number of times sampled
Select the number of times the CAN bus is sampled from "one time" and "three times."
• If one-time sampling is selected, the value sampled at only the end of Phase Segment1 is assumed to
be the value of the bit.
• If three-time sampling is selected, the value of the bit is determined by majority from three sampled
values, one sampled at the end of Phase Segment1 and the other sampled 1 Tq before and 2 Tq's
before that.
1
Tq period × number of Tq's in one bit
+ Phase Segment 2
13-75
CAN MODULE
13.4 Initializing the CAN Module
32180 Group User's Manual (Rev.1.0)

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents