Initializing The Can Module; Initialization Of The Can Module - Mitsubishi Electric M32R Series User Manual

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

Advertisement

13

13.4 Initializing the CAN Module

13.4.1 Initialization of the CAN Module

Before you perform 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, so be sure to select the functions of these pins. (Refer to Chapter 8, "Input/
Output Ports and Pin Functions."
(2) Setting the interrupt controller (ICU)
When you use CAN module interrupts, set the interrupt priority.
(3) Setting CAN Error Interrupt Mask and CAN Slot Interrupt Mask Registers
When you use CAN bus error interrupts, CAN error passive interrupts, CAN error bus-off
interrupts, or CAN slot interrupts, set each corresponding bit to 1 to enable interrupt requests.
(4) Setting 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.
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 shown below.
Tq = (CANBRP+1) /CPU clock
The baud rate is determined by the number of Tq's that comprise one bit. The equation to
calculate the baud rate is shown below.
Baud rate (bps) =
Number of Tq's for 1 bit = Synchronization Segment +
1
Tq period × number of Tq's for 1 bit
Propagation Segment +
Phase Segment 1 +
Phase Segment 2
13-56
CAN MODULE
13.4 Initializing the CAN Module
Ver.0.10

Advertisement

Table of Contents
loading

Table of Contents