Contents ..........................Preface ....................... Architecture ......................CAN Overview ......................1.1.1 Features ..................... 1.1.2 Block Diagram ............. 1.1.3 eCAN Compatibility With Other TI CAN Modules ................... The CAN Network and Module ..................1.2.1 CAN Protocol Overview ....................eCAN Controller Overview ................. 1.3.1 Standard CAN Controller (SCC) Mode .......................
Page 4
www.ti.com ....................2.18 Timer Management Unit ................... 2.18.1 Time Stamp Functions ....................2.18.2 Time-Out Functions ............2.18.3 Behavior/Usage of MTOF0/1 Bit in User Applications ......................2.19 Mailbox Layout ................. 2.19.1 Message Identifier Register (MSGID) .................... 2.19.2 CPU Mailbox Access ............... 2.19.3 Message-Control Register (MSGCTRL) .............
www.ti.com List of Figures ................eCAN Block Diagram and Interface Circuit ......................CAN Data Frame ..................Architecture of the eCAN Module ..................... eCAN-A Memory Map ..................... eCAN-B Memory Map ..................Mailbox-Enable Register (CANME) ..................Mailbox-Direction Register (CANMD) ............... Transmission-Request Set Register (CANTRS) ..............
Page 6
www.ti.com List of Tables ........................ Register Map .................... eCAN-A Mailbox RAM Layout ......... Addresses of LAM, MOTS and MOTO registers for mailboxes (eCAN-A) .................... eCAN-B Mailbox Ram Layout ........Addresses of LAM, MOTS, and MOTO Registers for Mailboxes (eCAN-B) ................Message Object Behavior Configuration ..............
• Hexadecimal numbers are shown with the suffix h. For example, the following number is 40 hexadecimal (decimal 64): 40h. Related Documentation From Texas Instruments The following documents describe the x281x device and related peripherals. Copies of these documents are available for downloading at www.ti.com.
Page 8
Related Documentation From Texas Instruments www.ti.com SPRU059— TMS320x28xx, 28xxx Serial Peripheral Interface (SPI) Reference Guide describes the SPI - a high-speed synchronous serial input/output (I/O) port - that allows a serial bit stream of programmed length (one to sixteen bits) to be shifted into and out of the device at a programmed bit-transfer rate.
Chapter 1 SPRU074F – May 2002 – Revised January 2009 Architecture The enhanced Controller Area Network (eCAN) module implemented in the C28x™ DSP is a full-CAN controller and is compatible with the CAN 2.0B standard (active). It uses established protocol to communicate serially with other controllers in electrically noisy environments.
CAN Overview www.ti.com CAN Overview Figure 1–1 shows the major blocks of the eCAN and the interface circuits. 1.1.1 Features The eCAN module has the following features: • Fully compliant with CAN protocol, version 2.0B • Supports data rates up to 1 Mbps •...
The eCAN module is identical to the “High-end CAN Controller (HECC)” used in the TMS470™ series microcontrollers from Texas Instruments with some minor changes. The eCAN module features several enhancements (such as increased number of mailboxes with individual acceptance masks, time stamping, etc.) over the CAN module featured in 240x™...
The CAN Network and Module www.ti.com The CAN Network and Module The controller area network (CAN) uses a serial multimaster communication protocol that efficiently supports distributed real-time control, with a very high level of security, and a communication rate of up to 1 Mbps.
eCAN Controller Overview www.ti.com Figure 1-3. Architecture of the eCAN Module CAN controller Message Controller Transmit Buffer Receive Buffer CAN Protocol Kernel (CPK) CAN Transceiver CAN Bus The receive and transmit buffers are transparent to the user and are not accessible by user code. Two functions of the CPK are to decode all messages received on the CAN bus according to the CAN protocol and to transfer these messages into a receive buffer.
eCAN Controller Overview www.ti.com When a message must be transmitted, the message controller transfers the message into the transmit buffer of the CPK in order to start the message transmission at the next bus-idle state. When more than one message must be transmitted, the message with the highest priority that is ready to be transmitted is transferred into the CPK by the message controller.
eCAN Controller Overview www.ti.com 1.3.2 Memory Map The eCAN module has two different address segments mapped in the memory. The first segment is used to access the control registers, the status registers, the acceptance masks, the time stamp, and the time-out of the message objects.
eCAN Controller Overview www.ti.com 1.3.3 eCAN Control and Status Registers The eCAN registers listed in Table 1-1 are used by the CPU to configure and control the CAN controller and the message objects. Table 1-1. Register Map REGISTER NAME ECAN-A ECAN-B SIZE DESCRIPTION...
Message Objects www.ti.com Message Objects The eCAN module has 32 different message objects (mailboxes). Each message object can be configured to either transmit or receive. Each message object has its individual acceptance mask. A message object consists of a message mailbox with: •...
Message Mailbox www.ti.com If more than one mailbox is configured as transmit mailbox and more than one corresponding TRS[n] is set, the messages are sent one after another in falling order beginning with the mailbox with the highest priority. In the SCC-compatibility mode, the priority of the mailbox transmission depends on the mailbox number. The highest mailbox number (=15) comprises the highest transmit priority.
Mailbox Enable Register (CANME) www.ti.com Mailbox Enable Register (CANME) This register is used to enable/disable individual mailboxes. Figure 2-1. Mailbox-Enable Register (CANME) CANME[31:0] R/W-0 LEGEND: R/W = Read/Write; -n = value after reset Table 2-1. Mailbox-Enable Register (CANME) Field Descriptions Field Value Description...
Mailbox-Direction Register (CANMD) www.ti.com Mailbox-Direction Register (CANMD) This register is used to configure a mailbox for transmit or receive operation. Figure 2-2. Mailbox-Direction Register (CANMD) CANMD[31:0] R/W-0 LEGEND: R/W = Read/Write; -n = value after reset Table 2-2. Mailbox-Direction Register (CANMD) Field Descriptions Field Value Description...
Transmission-Request Set Register (CANTRS) www.ti.com Transmission-Request Set Register (CANTRS) When mailbox n is ready to be transmitted, the CPU should set the TRS[n] bit to 1 to start the transmission. These bits are normally set by the CPU and cleared by the CAN module logic. The CAN module can set these bits for a remote frame request.
Transmission-Request-Reset Register (CANTRR) www.ti.com Transmission-Request-Reset Register (CANTRR) These bits can only be set by the CPU and reset by the internal logic. These bits are reset when a transmission is successful or is aborted. If the CPU tries to set a bit while the CAN tries to clear it, the bit is set.
Transmission-Acknowledge Register (CANTA) www.ti.com Transmission-Acknowledge Register (CANTA) If the message of mailbox n was sent successfully, the bit TA[n] is set. This also sets the GMIF0/GMIF1 (GIF0.15/GIF1.15) bit if the corresponding interrupt mask bit in the CANMIM register is set. The GMIF0/GMIF1 bit initiates an interrupt.
Abort-Acknowledge Register (CANAA) www.ti.com Abort-Acknowledge Register (CANAA) If the transmission of the message in mailbox n was aborted, the bit AA[n] is set and the AAIF (GIF.14) bit is set, which may generate an interrupt if enabled. The bits in CANAA are reset by writing a 1 from the CPU. Writing a 0 has no effect. If the CPU tries to reset a bit and the CAN tries to set the bit at the same time, the bit is set.
Received-Message-Pending Register (CANRMP) www.ti.com Received-Message-Pending Register (CANRMP) If mailbox n contains a received message, the bit RMP[n] of this register is set. These bits can be reset only by the CPU and set by the internal logic. A new incoming message overwrites the stored one if the OPC[n](OPC.31-0) bit is cleared, otherwise the next mailboxes are checked for a matching ID.
Received-Message-Lost Register (CANRML) www.ti.com Received-Message-Lost Register (CANRML) An RML[n] bit is set if an old message has been overwritten by a new one in mailbox n. These bits can only be reset by the CPU, and set by the internal logic. The bits can be cleared by a write access to the CANRMP register with a 1 at the corresponding bit location.
Remote-Frame-Pending Register (CANRFP) www.ti.com Remote-Frame-Pending Register (CANRFP) Whenever a remote frame request is received by the CAN module, the corresponding bit RFP[n] in the remote frame pending register is set. If a remote frame is stored in a receive mailbox (AAM=0, CANMD=1), the RFPn bit will not be set.
Page 35
Remote-Frame-Pending Register (CANRFP) www.ti.com The behavior of the message object n is configured with CANMD[n] (CANMD.31-0), the AAM (MSGID.29), and RTR (MSGCTRL.4). It shows how to configure a message object according to the desired behavior. To summarize, a message object can be configured with four different behaviors: 1.
Global Acceptance Mask Register (CANGAM) www.ti.com 2.10 Global Acceptance Mask Register (CANGAM) The global-acceptance mask is used by the eCAN in SCC mode. The global-acceptance mask is used for the mailboxes 6 to 15 if the AME bit (MSGID.30) of the corresponding mailbox is set. A received message is only stored in the first mailbox with a matching identifier.
Master Control Register (CANMC) www.ti.com 2.11 Master Control Register (CANMC) This register is used to control the settings of the CAN module. Some bits of the CANMC register are EALLOW protected. For read/write operations, only 32-bit access is supported. Figure 2-11. Master Control Register (CANMC) Reserved SUSP R/W-0...
Page 38
Master Control Register (CANMC) www.ti.com Table 2-11. Master Control Register (CANMC) Field Descriptions (continued) Field Value Description Power down mode request. This bit is automatically cleared by the eCAN module upon wakeup from low-power mode. This bit is EALLOW protected. The local power-down mode is requested.
Master Control Register (CANMC) www.ti.com 2.11.1 CAN Module Action in SUSPEND 1. If there is no traffic on the CAN bus and SUSPEND mode is requested, the node goes into SUSPEND mode. 2. If there is traffic on the CAN bus and SUSPEND mode is requested, the node goes into SUSPEND mode when the ongoing frame is over.
Bit-Timing Configuration Register (CANBTC) www.ti.com 2.12 Bit-Timing Configuration Register (CANBTC) The CANBTC register is used to configure the CAN node with the appropriate network-timing parameters. This register must be programmed before using the CAN module. This register is write-protected in user mode and can only be written in initialization mode (see Section 3.6.1).
Page 41
Bit-Timing Configuration Register (CANBTC) www.ti.com Field Value Description This parameter sets the number of samples used by the CAN module to determine the actual level of the CAN bus. When the SAM bit is set, the level determined by the CAN bus corresponds to the result from the majority decision of the last three values.
Error and Status Register (CANES) www.ti.com 2.13 Error and Status Register (CANES) The status of the CAN module is shown by the Error and Status Register (CANES) and the error counter registers, which are described in this section. The error and status register comprises information about the actual status of the CAN module and displays bus error flags as well as error status flags.
Page 43
Error and Status Register (CANES) www.ti.com Table 2-13. Error and Status Register (CANES) Field Descriptions (continued) Field Value Description Error-passive state The CAN module is in error-passive mode. CANTEC has reached 128. The CAN module is in error-active mode. Warning status One of the two error counters (CANREC or CANTEC) has reached the warning level of 96.
CAN Error Counter Registers (CANTEC/CANREC) www.ti.com 2.14 CAN Error Counter Registers (CANTEC/CANREC) The CAN module contains two error counters: the receive error counter (CANREC) and the transmit error counter (CANTEC). The values of both counters can be read via the CPU interface. These counters are incremented or decremented according to the CAN protocol specification version 2.0.
Interrupt Registers www.ti.com 2.15 Interrupt Registers Interrupts are controlled by the interrupt flag registers, interrupt mask registers and mailbox interrupt level registers. These registers are described in the following subsections. 2.15.1 Global Interrupt Flag Registers (CANGIF0/CANGIF1) These registers allow the CPU to identify the interrupt source. The interrupt flag bits are set if the corresponding interrupt condition did occur.
Interrupt Registers www.ti.com Table 2-14. Global Interrupt Flag Registers (CANGIF0/CANGIF1) Field Descriptions Field Value Description 31:18 Reserved Reserved. Reads are undefined and writes have no effect. MTOF0/1 Mailbox time-out flag. This bit is not available in the SCC mode. One of the mailboxes did not transmit or receive a message within the specified time frame. No time out for the mailboxes occurred.
Interrupt Registers www.ti.com 2.15.2 Global Interrupt Mask Register (CANGIM) The set up for the interrupt mask register is the same as for the interrupt flag register. If a bit is set, the corresponding interrupt is enabled. This register is EALLOW protected. Figure 2-18.
Page 49
Interrupt Registers www.ti.com Table 2-15. Global Interrupt Mask Register (CANGIM) Field Descriptions (continued) Field Value Description WLIM Warning level interrupt mask Enabled Disabled Reserved Reads are undefined and writes have no effect. Global interrupt level for the interrupts TCOF, WDIF, WUIF, BOIF, EPIF, RMLIF, AAIF and WLIF. All global interrupts are mapped to the ECAN1INT interrupt line.
Interrupt Registers www.ti.com 2.15.3 Mailbox Interrupt Mask Register (CANMIM) There is one interrupt flag available for each mailbox. This can be a receive or a transmit interrupt depending on the configuration of the mailbox. This register is EALLOW protected. Figure 2-19. Mailbox Interrupt Mask Register (CANMIM) MIM.31:0 R/W-0 LEGEND: R/W = Read/Write;...
Interrupt Registers www.ti.com 2.15.4 Mailbox Interrupt Level Register (CANMIL) Each of the 32 mailboxes may initiate an interrupt on one of the two interrupt lines. Depending on the setting in the mailbox interrupt level register (CANMIL), the interrupt is generated on ECAN0INT (MILn = 0) or on line ECAN1INT (MIL[n] = 1).
Overwrite Protection Control Register (CANOPC) www.ti.com 2.16 Overwrite Protection Control Register (CANOPC) If there is an overflow condition for mailbox n (RMP[n] is set to 1 and a new receive message would fit for mailbox n), the new message is stored depending on the settings in the CANOPC register. If the corresponding bit OPC[n] is set to 1, the old message is protected against being overwritten by the new message;...
eCAN I/O Control Registers (CANTIOC, CANRIOC) www.ti.com 2.17 eCAN I/O Control Registers (CANTIOC, CANRIOC) The CANTX and CANRX pins should be configured for CAN use. This is done using the CANTIOC and CANRIOC registers. Figure 2-22. TX I/O Control Register (CANTIOC) Reserved Reserved TXFU...
eCAN I/O Control Registers (CANTIOC, CANRIOC) www.ti.com Figure 2-23. RX I/O Control Register (CANRIOC) Reserved Reserved RXFU Reserved RWP- LEGEND: RWP = Read in all modes, write in EALLOW-mode only; R = Read only; -n = value after reset; x = indeterminate Table 2-20.
Timer Management Unit www.ti.com 2.18 Timer Management Unit Several functions are implemented in the eCAN to monitor the time when messages are transmitted/received. A separate state machine is included in the eCAN to handle the time-control functions. This state machine has lower priority when accessing the registers than the CAN state machine has.
Timer Management Unit www.ti.com 2.18.1.1 Time-Stamp Counter Register (CANTSC) This register holds the time-stamp counter value at any instant of time. This is a free-running 32-bit timer which is clocked by the bit clock of the CAN bus. For example, at a bit rate of 1 Mbps, CANTSC would increment every 1 µs.
Timer Management Unit www.ti.com 2.18.1.2 Message Object Time Stamp Registers (MOTS) This register holds the value of the TSC when the corresponding mailbox data was successfully transmitted or received. Each mailbox has its own MOTS register. Figure 2-25. Message Object Time Stamp Registers (MOTS) MOTS31:0 R/W-x LEGEND: R/W = Read/Write;...
Timer Management Unit www.ti.com 2.18.2 Time-Out Functions To ensure that all messages are sent or received within a predefined period, each mailbox has its own time-out register. If a message has not been sent or received by the time indicated in the time-out register and the corresponding bit TOC[n] is set in the TOC register, a flag is set in the time-out status register (TOS).
Timer Management Unit www.ti.com 2.18.2.2 Time-Out Control Register (CANTOC) This register controls whether or not time-out functionality is enabled for a given mailbox. Figure 2-27. Time-Out Control Register (CANTOC) TOC31:0 R/W-0 LEGEND: R/W = Read/Write; -n = value after reset Table 2-24.
Timer Management Unit www.ti.com 2.18.2.3 Time-Out Status Register (CANTOS) This register holds the status information of mailboxes that have timed out. Figure 2-28. Time-Out Status Register (CANTOS) TOS31:0 R/C-0 LEGEND: R/C = Read/Clear; -n = value after reset Table 2-25. Time-Out Status Register (CANTOS) Field Descriptions Field Value Description...
Mailbox Layout www.ti.com 2.19 Mailbox Layout The following four 32-bit registers comprise each mailbox: • MSGID – Stores the message ID • MSGCTRL – Defines number of bytes, transmission priority and remote frames • CANMDL – 4 bytes of data •...
Mailbox Layout www.ti.com Table 2-26. Message Identifier Register (MSGID) Field Descriptions (continued) Field Value Description 28:0 ID[28:0] Message identifier In standard identifier mode, if the IDE bit (MSGID.31) = 0, the message identifier is stored in bits ID.28:18. In this case, bits ID.17:0 have no meaning. In extended identifier mode, if the IDE bit (MSGID.31) = 1, the message identifier is stored in bits ID.28:0.
Mailbox Layout www.ti.com 2.19.3 Message-Control Register (MSGCTRL) For a transmit mailbox, this register specifies the number of bytes to be transmitted and the transmission priority. It also specifies the remote-frame operation. Note: As part of the CAN module initialization process, all the bits of the MSGCTRLn registers must first be initialized to zero before proceeding to initialize the various bit fields to the desired values.
Mailbox Layout www.ti.com 2.19.4 Message Data Registers (CANMDL, CANMDH) Eight bytes of the mailbox are used to store the data field of a CAN message. The setting of DBO (MC.10) determines the ordering of stored data. The data is transmitted or received from the CAN bus, starting with byte 0.
Acceptance Filter www.ti.com 2.20 Acceptance Filter The identifier of the incoming message is first compared to the message identifier of the mailbox (which is stored in the mailbox). Then, the appropriate acceptance mask is used to mask out the bits of the identifier that should not be compared.
Acceptance Filter www.ti.com Figure 2-35. Local-Acceptance-Mask Register (LAMn) LAMI Reserved LAMn[28:16] R/W-0 R/W-0 R/W-0 LAMn[15:0] R/W-0 LEGEND: R/W = Read/Write; -n = value after reset Table 2-28. Local-Acceptance-Mask Register (LAMn) Field Descriptions Field Value Description LAMI Local-acceptance-mask identifier extension bit Standard and extended frames can be received.
Chapter 3 SPRU074F – May 2002 – Revised January 2009 eCAN Configuration This section explains the process of initialization and describes the procedures to configure the eCAN module....................Topic Page ............CAN Module Initialization ............Steps to Configure eCAN .........
CAN Module Initialization www.ti.com CAN Module Initialization The CAN module must be initialized before the utilization. Initialization is only possible if the module is in initialization mode. Figure 3-1 is a flow chart showing the process. Programming CCR (CANMC.12) = 1 sets the initialization mode. The initialization can be performed only when CCE (CANES.4) = 1.
CAN Module Initialization www.ti.com 3.1.1 CAN Bit-Timing Configuration The CAN protocol specification partitions the nominal bit time into four different time segments: SYNC_SEG: This part of bit time is used to synchronize the various nodes on the bus. An edge is expected to lie within this segment.
CAN Module Initialization www.ti.com Where bit-time is the number of time quanta (TQ) per bit. SYSCLKOUT is the CAN module system clock frequency, which is the same as the CPU clock frequency. BRP is the value of BRP (CANBTC.23-16). Bit-time is defined as follows: Bit-time = (TSEG1 + 1) + (TSEG2 + 1) + 1...
CAN Module Initialization www.ti.com 3.1.4 Bit Configuration Parameters for 100-MHz CAN Clock Table 3-4 shows how the BRP field may be changed to achieve different bit rates with a BT of 10 for an 80% SP. Table 3-4. BRP Field for Bit Rates (BT = 10, TSEG1 = 6, TSEG2 = 1, Sampling Point = 80%) CAN Bus Speed...
Steps to Configure eCAN www.ti.com 3.1.5 EALLOW Protection To protect against inadvertent modification, some critical registers/bits of the eCAN module are EALLOW protected. These registers/bits can be changed only if the EALLOW protection has been disabled. Following are the registers/ bits that are EALLOW protected in the eCAN module: •...
Steps to Configure eCAN www.ti.com 3.2.1 Configuring a Mailbox for Transmit To transmit a message, the following steps need to be performed (in this example, for mailbox 1): 1. Clear the appropriate bit in the CANTRS register to 0: Clear CANTRS.1 = 0 (Writing a 0 to TRS has no effect; instead, set TRR.1 and wait until TRS.1 clears.) If the RTR bit is set, the TRS bit can send a remote frame.
Handling of Remote Frame Mailboxes www.ti.com 4. Configure the mailbox as a receive mailbox by setting the corresponding flag in the mailbox direction register (CANMD.3 = 1). Make sure no other bits in this register are affected by this operation. 5.
Interrupts www.ti.com 3. Set the CANTRS flag for that mailbox. Since the mailbox is configured as receive, it only sends a remote request message to the other node. Set CANTRS.3 = 1 4. The module stores the answer in that mailbox and sets the RMP bit when it is received. This action can initiate an interrupt.
Interrupts www.ti.com – Bus-off interrupt: the CAN module enters the bus-off state – Error-passive interrupt: the CAN module enters the error-passive mode – Warning level interrupt: one or both error counters are greater than or equal to 96 – Time-stamp counter overflow interrupt (eCAN only): the time-stamp counter had an overflow Figure 3-3.
Interrupts www.ti.com 3.4.1 Interrupts Scheme The interrupt flags are set if the corresponding interrupt condition occurred. The system interrupt flags are set depending on the setting of GIL (CANGIM.2). If set, the global interrupts set the bits in the CANGIF1 register, otherwise they set in the CANGIF0 register.
Interrupts www.ti.com 3.4.3 Interrupt Handling The CPU is interrupted by asserting one of the two interrupt lines. After handling the interrupt, which should generally also clear the interrupt source, the interrupt flag must be cleared by the CPU. To do this, the interrupt flag must be cleared in the CANGIF0 or CANGIF1 register.
Page 79
Interrupts www.ti.com This configuration puts all mailbox interrupts on line 1 and all system interrupts on line 0. Thus, the CPU can handle all system interrupts (which are always serious) with high priority, and the mailbox interrupts (on the other line) with a lower priority. All messages with a high priority can also be directed to the interrupt line 0.
CAN Power-Down Mode www.ti.com 2. The PIEACK bit corresponding corresponding to the CAN module must be written with a 1, which can be accomplished with the following C language statement: PieCtrlRegs.PIEACK.bit.ACK9 = 1; // Enables PIE to drive a pulse into the CPU 3.
CAN Power-Down Mode www.ti.com 2. The CAN module has signaled to the CPU that it is ready to enter LPM. In other words, device low-power modes should be entered into only after putting the CAN module in local power-down mode. 3.5.3 Enabling/Disabling Clock to the CAN Module The CAN module cannot be used unless the clock to the module is enabled.
Page 82
eCAN Configuration SPRU074F – May 2002 – Revised January 2009 Submit Documentation Feedback...
Appendix A SPRU074F – May 2002 – Revised January 2009 Revision History This document was revised to SPRU074F from SPRU074E. The scope of the revisions was limited to technical changes as described in Table A-1. This appendix lists only revisions made in the most recent version.
Page 84
IMPORTANT NOTICE Texas Instruments Incorporated and its subsidiaries (TI) reserve the right to make corrections, modifications, enhancements, improvements, and other changes to its products and services at any time and to discontinue any product or service without notice. Customers should obtain the latest relevant information before placing orders and should verify that such information is current and complete.
Need help?
Do you have a question about the TMS320x281 series and is the answer not in the manual?
Questions and answers