
NUC970 Technical Reference Manual
Publication Release Date: Dec. 15, 2015
- 773 -
Revision V1.30
NUC97
0
T
E
CHNIC
A
L
RE
F
E
RE
N
CE
MA
NUA
L
5.24.4 Basic Configuration
Before using CAN
functionality, it’s necessary to configure I/O pins as the CAN function and enable
CAN
’s clock.
Write 0xC to MFP_GPB10 (SYS_GPB_MFPH[11:8]) and MFP_GPB11 (SYS_GPB_MFPH[15:12])
configures pin PB.10 and PB.11 to be CAN0_RX and CAN0_TX respectively.
Write 0xC to MFP_GPH2 (SYS_GPH_MFPL[11:8]) and MFP_GPH3 (SYS_GPH_MFPL[15:12])
configures pin PH.2 and PH.3 to be CAN0_RX and CAN0_TX respectively.
Write 0xC to MFP_GPI3 (SYS_GPI_MFPL[15:12]) and MFP_GPI4 (SYS_GPI_MFPL[19:16])
configures pin PI.3 and PI.4 to be CAN0_RX and CAN0_TX respectively.
Write 0xC to MFP_GPH14 (SYS_GPH_MFPH[27:24]) and MFP_GPH15 (SYS_GPH_MFPH[31:28])
configures pin PH.14 and PH.15 to be CAN1_RX and CAN1_TX respectively.
Please note that configure PB.10, PH.2 and PI.3 to be CAN0_RX functionality in the same time or
configure PB.11, PH.3 and PI.4 to be CAN0_TX functionality in the same time is prohibited.
To enable CAN
’s clock, please refer to register CLK_PCLKEN1. Set CAN0 (CLK_PCLKEN1[8]) high
to enable CAN0 clock while set CAN1 (CLK_PCLKEN1[9]) high to enable CAN1 clock.
5.24.5 Functional Description
Software Initialization
5.24.5.1
The software initialization is started by setting the Init bit in the CAN Control Register, either by a
software or a hardware reset, or by going to Bus_Off state.
While the Init bit is set, all messages transfer to and from the CAN bus are stopped and the status of
the CAN_TX output pin is recessive (HIGH). The Error Management Logic (EML) counters are
unchanged. Setting the Init bit does not change any configuration register.
To initialize the CAN Controller, software has to set up the Bit Timing Register and each Message
Object. If a Message Object is not required, the corresponding MsgVal bit should be cleared.
Otherwise, the entire Message Object has to be initialized.
Access to the Bit Timing Register and to the Baud Rate Prescaler Extension Register for configuring
bit timing is enabled when both the Init and CCE bits in the CAN Control Register are set.
Resetting the Init bit (by software only) finishes the software initialization. Later, the Bit Stream
Processor (BSP) (see Section 5.13.6.10: Configuring the Bit Timing) synchronizes itself to the data
transfer on the CAN bus by waiting for the occurrence of a sequence of 11 consecutive recessive bits
The initialization of the Message Objects is independent of Init and can be done on the fly, but the
Message Objects should all be configured to particular identifiers or set to not valid before the BSP
starts the message transfer.
To change the configuration of a Message Object during normal operation, the software has to start by
resetting the corresponding MsgVal bit. When the configuration is completed, MsgVal is set again.
CAN Message Transfer
5.24.5.2
Once the C_CAN is initialized and Init bit is reset to zero, the C_CAN Core synchronizes itself to the
CAN bus and starts the message transfer.
Received messages are stored in their appropriate Message Objects if they pass the Message
Handler’s acceptance filtering. The whole message including all arbitration bits, DLC and eight data
bytes are stored in the Message Object. If the Identifier Mask is used, the arbitration bits which are