4.2. CAN Module
4.2.1. Acronyms and Definitions
Abbreviation/Term |
Explanation |
---|---|
AUTOSAR |
Automotive Open System Architecture |
RTE |
Runtime Environment |
BSW |
Basic Software |
GPIO |
General Purpose Input Output |
MCAL |
Micro Controller Abstraction Layer |
API |
Application Programming Interface |
DET |
Default Error Tracer |
HW |
Hardware |
SW |
Software |
I/O |
Input/Output |
CAN |
Controller Area Network |
CanIf |
Can Interface |
L-PDU |
Data Link Layer Protocol Data Unit. Consists of Identifier, Data Length and Data (SDU). |
DLC |
Data Length Code |
OS |
Operating System |
4.2.2. Introduction
This document details AUTOSAR BSW CAN module implementation
Supported AUTOSAR Release |
4.3.1 |
---|---|
Supported Configuration Variants |
Post-build, Pre-Compile |
Vendor ID |
CAN_VENDOR_ID (44) |
Module ID |
CAN_MODULE_ID (80) |
Supported Platform |
AM263Px |
The CAN driver provides services for basic transmission and reception of CAN frames in both interrupt and polling mode. These components can be used by an application.

Fig. 4.19 Can MCAL AUTOSAR
4.2.3. Functional Overview
The CAN module initializes and controls the internal CAN Controllers of the microcontroller. It provides services to write, read, and configure mailboxes of the Can controllers
4.2.3.1. Initialization
Can_Init () must be called to initialize the CAN driver at power on and sets controller independent init values. This will also set the controllers to CAN_CS_STOPPED.
4.2.3.2. States
There are 4 states in which the CAN hardware/driver can be:
CAN_CS_UNINT: This is the state when the Hardware is just started.
CAN_CS_STOPPED: This is the state in which Hardware is in when after the initialization routine is called. CAN controller be fully initialized but does not participate in the bus transactions.
CAN_CS_STARTED: This is the state in which hardware is in when it is fully operational i.e.., it is sending and receive messages from the bus on CAN network.
CAN_CS_SLEEP: This is the state in which the hardware is in when the controller is sleeping. Changing the mode via Can_SetControllerMode ().
Following modes changes are supported:
CAN_CS_STARTED
CAN_CS_STOPPED
CAN_CS_SLEEP
The figure below taken from the AUTOSAR specification shows the state transitions for different function calls and events:

Fig. 4.20 CAN channel states and state transitions
4.2.3.3. CAN operating modes
The CAN module has a very simple state machine, with the two states CAN_UNINIT and CAN_READY. After power-up/reset, the CAN module shall be in the state CAN_UNINIT.

Fig. 4.21 CAN driver modes
4.2.3.4. Assumptions
None
4.2.3.5. Limitations
CAN Wake mode is not supported.
4.2.3.6. Design overview
Will be updated in future release
4.2.4. Hardware Features
4.2.4.1. Hardware Features supported
Conforms with CAN Protocol 2.0 A, B and ISO 11898-1:2015
Full CAN FD support (up to 64 data bytes)
1-Mbps nominal bit rate, 5-Mbps data bit rate
Loop-back mode for self-test
AUTOSAR and SAE J1939 support
Maskable interrupt (two configurable interrupt lines and clock stop or wakeup)
Two clock domains (CAN clock and host clock)
Clock stop and wakeup support
Up to 32 dedicated transmit buffers
Configurable transmit FIFO, up to 32 elements
Configurable transmit queue, up to 32 elements
Configurable transmit Event FIFO, up to 32 elements
Up to 64 dedicated receive buffers
Two configurable receive FIFOs, up to 64 elements each
Up to 128 filter elements
Parity/ECC support - Message RAM single error correction and double error detection (SECDED) mechanism.
Timestamp Counter.
4.2.4.2. AUTOSAR Features supported
8 CAN Controllers for AM263Px.
Supports transmission and reception of Classic.
Frames through CAN (CAN FD Controller).
Initialization of CAN controller HW.
Transmitting of CAN Frames and confirmation.
Reception of the CAN Frames.
Polling modes for Read / Write / BusOff confirmations.
Mailbox objects – Full and Basic filters for Rx.
Use of Software Delays according to configured timeout and number of ticks to check for timeouts.
Mixed Mode Operation.
Triggered transmission API.
LPDU Callback function.
4.2.4.3. Not supported Features
Register Readback for MCAN controller
Support for pretend networking
CAN Wake mode is not supported.
4.2.4.4. Non compliance
4.2.4.4.1. Deviations to requirements (Requirement Traceability)
4.2.4.4.1.1. Deviation of requirements against AUTOSAR specification requirements
Will be updated in future release
4.2.5. Source files
Static source C Files are defined below
📦AM263Px
┣ 📂build
┣ 📂mcal
┃ ┣ 📂Can
┃ ┃ ┣ 📂include
┃ ┃ ┃ ┣ 📜Can.h : Contains the API’s of the Can driver to be used by upper layers.
┃ ┃ ┃ ┣ 📜Can_Irq.h : Contains ISR function declaration.
┃ ┃ ┣ 📂src
┃ ┃ ┃ ┣ 📜Can.c : Contains the implementation of the API’s for Can driver.
┃ ┃ ┃ ┣ 📜Can_Irq.c : contains the implementation for Can interrupts handlers.
┃ ┃ ┣ 📂V0
┃ ┃ ┃ ┗ 📜Can_Mcan.c : Contains Internal Functions Definitions
┃ ┃ ┃ ┗ 📜Can_Priv.c : Contains Functions that support the API’s for Can driver
┃ ┃ ┃ ┣ 📜Can_Priv.h : Contains data structures and Internal function declarations.
┃ ┃ ┃ ┗ 📜mcan.c : Contains hardware Functions Definitions
┃ ┃ ┃ ┗ 📜mcan.h : Contains hardware Functions declarations and structures
┃ ┃ ┗ 📜Makefile
┃ 📂mcal_config
┃ 📂mcal_docs
┃ 📜README.txt
Plugin files are defined below in the table.
Plugin Files |
Description |
---|---|
Can_Cfg.h |
Contains the Precompile switches, Macros for CAN controllers, Hardware Objects etc. |
Can_PBcfg.c |
Contains all controllers Post-Build Configuration parameters |
Can_Cfg.c |
Contains all controllers Pre-Compile Configuration parameters |

Fig. 4.22 Can Header File Structure
4.2.6. Module requirements
Please refer Software Product Specification document provided as part of CSP.
4.2.6.1. Memory Mapping
Memory Mapping Sections |
CAN_CODE |
CAN_CODE_ISR |
CAN_VAR_NO_INIT |
CAN_VAR_ZERO_INIT |
CAN_PBCFG |
CAN_PBCFG_ROOT |
---|---|---|---|---|---|---|
CAN_START_SEC_VAR_INIT_UNSPECIFIED (.bss) |
X |
|||||
CAN_STOP_SEC_VAR_INIT_UNSPECIFIED |
X |
|||||
CAN_START_SEC_CODE_APPL (.text) |
X |
|||||
CAN_STOP_SEC_CODE_APPL |
X |
|||||
CAN_START_SEC_VAR_UNSPECIFIED (.bss) |
x |
|||||
CAN_STOP_SEC_VAR_UNSPECIFIED |
x |
|||||
CAN_START_SEC_CODE(.text) |
x |
|||||
CAN_STOP_SEC_CODE |
x |
|||||
CAN_START_SEC_PBCFG (.data) |
X |
|||||
CAN_STOP_SEC_PBCFG |
X |
|||||
CAN_START_SEC_PBCFG_ROOT (.const) |
X |
|||||
CAN_STOP_SEC_PBCFG_ROOT |
X |
4.2.6.2. Scheduling
Schedule Function API |
Description |
---|---|
Can_MainFunction_Write |
This function performs the polling of TX confirmation when CAN_TX_PROCESSING is set to POLLING |
Can_MainFunction_Read |
This function performs the polling of RX indications when CAN_RX_PROCESSING is set to POLLING. |
Can_MainFunction_BusOff |
This function performs the polling of bus-off events that are configured statically as ‘to be polled’. |
Can_MainFunction_Wakeup |
This function performs the polling of wake-up events that are configured statically as ‘to be polled’. |
Can_MainFunction_Mode |
This function performs the polling of CAN controller mode transitions. |
4.2.6.2.1. SchM
Beside the OS the BSW Scheduler provides functions that module CAN calls at begin and end of critical sections. The BSW scheduler can also call CAN Main functions.
4.2.6.2.2. Critical Sections
There is only one critical section in this driver. Within these sections all read /modify / write accesses to internal CAN status variables must be protected. Therefore, switching to tasks that also access CAN must be avoided and all CAN interrupts must be suspended. This is managed internally by CAN Driver.
4.2.6.3. Error handling
4.2.6.3.1. Development Error Reporting
Development errors are reported to the DET using the service Det_ReportError(),when enabled. The driver interface contains the MACRO declaration of the error codes to be returned.
4.2.6.3.1.1. Error codes
Type of Error |
Related Error code |
Value (Hex) |
---|---|---|
API service called with wrong parameter pointer |
CAN_E_PARAM_POINTER |
0x01 |
API service called with wrong hardware handle |
CAN_E_PARAM_HANDLE |
0x02 |
API service called with wrong data length |
CAN_E_PARAM_DATA_LENGTH |
0x03 |
API service called with wrong parameter Controller |
CAN_E_PARAM_CONTROLLER |
0x04 |
API service used without initialization |
CAN_E_UNINIT |
0x05 |
Invalid transition for the current mode. |
CAN_E_TRANSITION |
0x06 |
Parameter baud rate has an invalid value. |
CAN_E_PARAM_BAUDRATE |
0x07 |
invalid ICOM configuration Id |
CAN_E_ICOM_CONFIG_INVALID |
0x08 |
Invalid Configuration set selection. |
CAN_E_INIT_FAILED |
0x09 |
4.2.6.3.1.2. Runtime Error
Type of Error |
Related Error code |
Value (Hex) |
---|---|---|
Received CAN message is lost |
CAN_E_DATALOST |
0x01 |
4.2.6.3.2. DEM Error
Type of Error |
Related Error Code |
Description |
---|---|---|
Assigned by DEM |
CAN_E_HARDWARE_ERROR |
This error is raised when CAN register setting timeout occurs. |
4.2.7. Used resources
4.2.7.1. Interrupt Handling
The Driver doesn’t register any interrupts handler (ISR), it’s expected that consumer of this driver registers the required interrupt handler.
AUTOSAR_SWS_CANDriver section: 10 Configuration specification, details the expected behavior and control flow for ISR implementation, please refer the same.
For every CAN Instance, an ISR requires to be registered. The Interrupt number associated with instance of the CAN is detailed in TRM (also, please refer the Example application). Interrupt type should be selected in CAN plugin.
Two interrupt routines are provided by the CAN driver. The ISR’s are in the file Can_Irq.c User might edit it for adapting for the suitable OS. The current support is for the NON-OS Interrupts structure. CAN interrupts are hooked up on the Interrupt 0 line (IE0).
Following are the CAN controllers, its respective ISRs for each CAN Controller in AM263Px:
Can Controllers |
ISR Routines |
---|---|
MCAN0 |
Can_0_Int0ISR() |
MCAN0 Error |
Can_0_Int1ISR() |
MCAN1 |
Can_1_Int0ISR() |
MCAN1 Error |
Can_1_Int1ISR() |
MCAN2 |
Can_2_Int0ISR() |
MCAN2 Error |
Can_2_Int1ISR() |
MCAN3 |
Can_3_Int0ISR() |
MCAN3 Error |
Can_3_Int1ISR() |
MCAN4 |
Can_4_Int0ISR() |
MCAN4 Error |
Can_4_Int1ISR() |
MCAN5 |
Can_5_Int0ISR() |
MCAN5 Error |
Can_5_Int1ISR() |
MCAN6 |
Can_6_Int0ISR() |
MCAN6 Error |
Can_6_Int1ISR() |
MCAN7 |
Can_7_Int0ISR() |
MCAN7 Error |
Can_7_Int1ISR() |
Can_0_Int0ISR For AM263Px device, this ISR is called on detection of an event on interrupt line 0 for the MCAN0/MCANA controller. Transmission and reception related events including error events and ECC error events are managed in this ISR.
Can_0_Int1ISR For AM263Px device, This function manages the ECC related events for MCAN0/MCANA module. The ECC events for MCAN1 can only be configured and detected via ESM module. So, for detecting the ECC errors for the MCAN0/MCANA module the application needs to register and configure the ESM to generate interrupt for ECC Errors. This function can then be called to manage the ECC related events. Note: MCAN0/MCANA Interrupt line 1 can only be used for ECC and is not supported for normal interrupt functionality in the configurator
Can_1_Int0ISR For AM263Px device, This ISR is called on detection of an event on interrupt line 0 of the MCAN1/MCANB controller.Transmission and reception related events including error events are managed in this ISR.
Can_1_Int1ISR For AM263Px device, This function manages the ECC related events for MCAN1/MCANB module. The ECC events for MCAN can only be configured and detected via ESM module. So, for detecting the ECC errors for the MCAN module, the application needs to register and configure the ESM to generate interrupt for ECC Errors. This function can then be called to manage the ECC related events. Note: MCAN1/MCANB Interrupt line 1 can only be used for ECC and is not supported for normal interrupt functionality in the configurator
Can_2_Int0ISR For AM263Px device, This ISR is called on detection of an event on interrupt line 0 of the MCAN2 controller.Transmission and reception related events including error events are managed in this ISR.
Can_2_Int1ISR_Fun For AM263Px device, This function manages the ECC related events for MCAN2 module. The ECC events for MCAN can only be configured and detected via ESM module. So, for detecting the ECC errors for the MCAN module, the application needs to register and configure the ESM to generate interrupt for ECC Errors (for MCAN module). This function can then be called to manage the ECC related events. Note: MCAN2 Interrupt line 1 can only be used for ECC and is not supported for normal interrupt functionality in the configurator
Can_3_Int0ISR For AM263Px device, This ISR is called on detection of an event on interrupt line 0 of the MCAN3 controller.Transmission and reception related events including error events are managed in this ISR.
Can_3_Int1ISR_Fun For AM263Px device, This function manages the ECC related events for MCAN3 module. The ECC events for MCAN can only be configured and detected via ESM module. So, for detecting the ECC errors for the MCAN module, the application needs to register and configure the ESM to generate interrupt for ECC Errors (for MCAN module). This function can then be called to manage the ECC related events. Note: MCAN3 Interrupt line 1 can only be used for ECC and is not supported for normal interrupt functionality in the configurator
Can_4_Int0ISR For AM263Px device, This ISR is called on detection of an event on interrupt line 0 of the MCAN4 controller. Transmission and reception related events including error events are managed in this ISR.
Can_4_Int1ISR_Fun For AM263Px device, This function manages the ECC related events for MCAN4 module. The ECC events for MCAN can only be configured and detected via ESM module. So, for detecting the ECC errors for the MCAN module, the application needs to register and configure the ESM to generate interrupt for ECC Errors (for MCAN module). This function can then be called to manage the ECC related events. Note: MCAN4 Interrupt line 1 can only be used for ECC and is not supported for normal interrupt functionality in the configurator
Can_5_Int0ISR For AM263Px device, This ISR is called on detection of an event on interrupt line 0 of the MCAN5 controller. Transmission and reception related events including error events are managed in this ISR.
Can_5_Int1ISR_Fun For AM263Px device, This function manages the ECC related events for MCAN5 module. The ECC events for MCAN can only be configured and detected via ESM module. So, for detecting the ECC errors for the MCAN module, the application needs to register and configure the ESM to generate interrupt for ECC Errors (for MCAN module). This function can then be called to manage the ECC related events. Note: MCAN5 Interrupt line 1 can only be used for ECC and is not supported for normal interrupt functionality in the configurator
Can_6_Int0ISR For AM263Px device, This ISR is called on detection of an event on interrupt line 0 of the MCAN6 controller. Transmission and reception related events including error events are managed in this ISR.
Can_6_Int1ISR_Fun For AM263Px device, This function manages the ECC related events for MCAN2 module. The ECC events for MCAN can only be configured and detected via ESM module. So, for detecting the ECC errors for the MCAN module, the application needs to register and configure the ESM to generate interrupt for ECC Errors (for MCAN module). This function can then be called to manage the ECC related events. Note: MCAN6 Interrupt line 1 can only be used for ECC and is not supported for normal interrupt functionality in the configurator
Can_7_Int0ISR For AM263Px device, This ISR is called on detection of an event on interrupt line 0 of the MCAN7 controller. Transmission and reception related events including error events are managed in this ISR.
Can_7_Int1ISR_Fun For AM263Px device, This function manages the ECC related events for MCAN2 module. The ECC events for MCAN can only be configured and detected via ESM module. So, for detecting the ECC errors for the MCAN module, the application needs to register and configure the ESM to generate interrupt for ECC Errors (for MCAN module). This function can then be called to manage the ECC related events. Note: MCAN7 Interrupt line 1 can only be used for ECC and is not supported for normal interrupt functionality in the configurator
4.2.8. Integration description
4.2.8.1. Dependent modules
4.2.8.1.1. MCU
The CAN Modules expects the MCU modules to enable the MCAN controller. The Clock configuration should be configured in CAN module to select the correct clock source in the parameter “ CanCpuClockRef “.

Fig. 4.23 Clock Reference in MCU module
4.2.8.1.2. Port
The CAN Modules expects that pinmux is set correctly to configure the MCAN TX/RX pins for CAN mode. This is done by the PORT driver.
4.2.8.1.3. OS
An operating system can be used for task scheduling, interrupt handling, global suspend and restore of interrupts and creating of the Interrupt Vector Table. The CAN module may use AUTOSAR OS to suspend and restore global interrupts.
4.2.8.1.4. DET
The CAN module depends on the DET (by default) to report development errors.The DET can be replaced optionally by an equivalent component which is responsible to recognize development errors, if no DET component is available.
4.2.8.1.5. DEM
By default, production code related errors are reported to the DEM using the service DEM_ReportErrorStatus().
Note: Dem Event is enable only if $(Module_Name)DemEventParameterRefs
is enabled.
4.2.8.1.6. Callback Notification
At its configurable interfaces the CAN defines notifications that can be mapped to callback functions provided by other modules. The mapping is not statically defined by the CAN but can be performed at configuration time. The function prototypes that can be used for the configuration have to match the appropriate function prototype signatures, which are described in the following.
Can_ErrorNotification: This is of type Can_ErrNotifyType which is defined in Can.h file. This is called to report back the ECC error status to the application when ECC error interrupt happens.
4.2.8.2. Multi-core and Resource allocator
Not Supported
4.2.9. Configuration
The Can Driver implementation supports multiple configuration variants The driver expects generated Can_Cfg.h to be present as input file. The associated Can driver configuration generated source files are Can_Cfg.c and Can_PBcfg.c if Post-Build config variant is selected, only Can_Cfg.c if Pre-Compile variant is selected
The generated configuration files should not be modified manually. The config tool Elektrobit Tresos should be used to modify the configuration files.
The CAN is configured through GUI in Post-Build and Pre-Compile Variants.
Refer AUTOSAR_SWS_CANDriver section: 10 Configuration specification for configuration parameters details
Variants |
Configured Files |
---|---|
PostBuild |
Can_Cfg.c, Can_PBcfg.c , Can_Cfg.h |
Pre-Compile |
Can_Cfg.c , Can_Cfg.h |
4.2.9.1. Parameter Description
4.2.9.1.1. Standard Configuration
Standard Parameters |
Description |
Default Value |
Range |
Unit/Datatype |
---|---|---|---|---|
CanControllerId |
This parameter provides the controller ID which is unique in a given CAN Driver. The value for this parameter starts with 0 and continue without any gaps |
0 |
0..255 |
INTEGER |
CanControllerActivation |
Defines if a CAN controller is used in the configuration |
FALSE |
TRUE FALSE |
BOOLEAN |
CanControllerBaseAddress |
Specifies the CAN controller base address. |
33816576 |
INTEGER |
|
CanWakeupProcessing |
Enables / disables API Can_MainFunction_Wakeup() for handling wakeup events in polling mode. |
INTERRUPT |
INTERRUPT POLLING |
INTEGER |
CanWakeupSupport |
CAN driver support for wakeup over CAN Bus |
FALSE |
TRUE FALSE |
INTEGER |
CanControllerBaudRate |
Specifies the baudrate of the controller in kbps |
500 |
0..2000 |
INTEGER |
CanControllerBaudRateConfigID |
Uniquely identifies a specific baud rate configuration. This ID is used by SetBaudrate API |
0 |
0..65535 |
INTEGER |
CanControllerPropSeg |
Specifies propagation delay in time quantas. |
8 |
0..255 |
INTEGER |
CanControllerSeg1 |
Specifies phase segment 1 in time quantas |
5 |
0..255 |
INTEGER |
CanControllerSeg2 |
Specifies phase segment 1 in time quantas |
4 |
0..255 |
INTEGER |
CanControllerSyncJumpWidth |
Specifies the synchronization jump width for the controller in time quantas |
1 |
0..255 |
INTEGER |
CanControllerFdBaudRate |
Specifies the data segment baud rate of the controller in kbps |
5000 |
0..16000 |
INTEGER |
CanControllerTrcvDelayCompensationOffset |
Specifies the Transceiver Delay Compensation Offset in ns. If not specified Transceiver Delay Compensation is disabled. |
180 |
0..400 |
INTEGER |
CanControllerTxBitRateSwitch |
Specifies if the bit rate switching shall be used for transmissions. |
TRUE |
TRUE FALSE |
BOOLEAN |
CanFdPaddingValue |
Specifies the value which is used to pad unspecified data in CAN FD frames > 8 bytes for transmission. This is necessary due to the discrete possible values of the DLC if > 8 bytes. |
0 |
0..255 |
INTEGER |
CanHandleType |
Specifies the type (Full-CAN or Basic-CAN) of a hardware object. |
FULL |
BASIC FULL |
ENUMERATION |
CanHardwareObjectUsesPolling |
Enables polling of this hardware object. |
FALSE |
TRUE FALSE |
BOOLEAN |
CanHwObjectCount |
Number of hardware objects used to implement one HOH. In case of a HRH this parameter defines the number of elements in the hardware FIFO or the number of shadow buffers, in case of a HTH it defines the number of hardware objects used for multiplexed transmission or for a hardware FIFO used by a FullCAN HTH. |
1 |
1..65535 |
INTEGER |
CanIdType |
Specifies whether the IdValue is of type |
STANDARD |
EXTENDED MIXED STANDARD |
ENUMERATION |
CanObjectId |
Holds the handle ID of HRH or HTH. The value of this parameter is unique in a given CAN Driver, and it should start with 0 and continue without any gaps |
0 |
0..65535 |
INTEGER |
CanObjectType |
Specifies if the HardwareObject is used as Transmit or as Receive object |
TRANSMIT |
RECEIVE TRANSMIT |
ENUMERATION |
CanTriggerTransmitEnable |
This parameter defines if or if not Can supports the trigger-transmit API for this handle. |
TRUE |
TRUE FALSE |
BOOLEAN |
CanHwFilterCode |
Specifies (together with the filter mask) the identifiers range that passes the hardware filter. |
0 |
0..4294967295 |
INTEGER |
CanHwFilterMask |
Describes a mask for hardware-based filtering of CAN identifiers. The CAN identifiers of incoming messages are masked with the appropriate CanFilterMaskValue. Bits holding a 0 mean don’t care, i.e. do not compare the message’s identifier in the respective bit position. |
0 |
0..0xFFFFFFFF |
INTEGER |
CanDevErrorDetect |
Switches the Development Error Detection and Notification ON or OFF. |
FALSE |
TRUE FALSE |
BOOLEAN |
CanIdenticalIdCancellation |
Enables/disables cancellation of pending PDUs with identical ID. |
FALSE |
TRUE FALSE |
BOOLEAN |
CanIndex |
Specifies the InstanceId of this module instance. If only one instance is present it shall have the Id 0. |
0 |
0..255 |
INTEGER |
CanMainFunctionModePeriod |
This parameter describes the period for cyclic call to Can_MainFunction_Mode. Unit is seconds. |
10 |
0.001..65.535 |
FLOAT |
CanMainFunctionBusoffPeriod |
This parameter describes the period for cyclic call to Can_MainFunction_Busoff. Unit is seconds. |
10 |
0.001..65.535 |
FLOAT |
CanSetBaudrateApi |
The support of the Can_SetBaudrate API is optional.If this parameter is set to true the Can_SetBaudrate API shall be supported. Otherwise the API is not supported. |
TRUE |
TRUE FALSE |
BOOLEAN |
CanTimeoutDuration |
Specifies the maximum time for blocking function until a timeout is detected. Unit is seconds |
20 |
0.001..65.535 |
FLOAT |
CanVersionInfoApi |
Switches the Can_GetVersionInfo() API ON or OFF. |
TRUE |
TRUE FALSE |
BOOLEAN |
4.2.9.1.2. IP Specific Configuration
Standard Parameters |
Description |
Default Value |
Range |
Unit/DataType |
---|---|---|---|---|
CanControllerInstance |
Selects Can Controller Instance. |
MCAN0 |
MCAN0 MCAN1 MCAN2 MCAN3 |
ENUMERATION |
CanErrorNotification |
Callback function for ECC Error and Parity error in case of AM273X |
NULL_PTR |
Not Applicable |
|
CanControllerType |
This parameter provides the controller Type. The value for this parameter is calculated by driver runtime |
0 |
0..255 |
INTEGER |
CanDisableAutoRetranmission |
Disable auto retransmission on xmit error |
TRUE |
TRUE FALSE |
BOOLEAN |
CanDeInitApi |
Adds / removes the service Can_DeInit() from the code. |
TRUE |
TRUE FALSE |
BOOLEAN |
CanHardwareCancellation |
Specifies if hardware cancellation shall be supported.ON or OFF |
FALSE |
TRUE FALSE |
BOOLEAN |
CanDefaultOSCounterId |
Default Os Counter Id if node reference to OsCounter ref CanOsCounterRef is not set |
0 |
0..16 |
INTEGER |
CanMaxNrOfTxObjects |
Number of Transmit Objects |
3 |
0..3 |
INTEGER |
CanTypeofInterruptFunction |
Type of ISR function |
CAN_ISR_CAT2 |
CAN_ISR_VOID CAN_ISR_CAT1 CAN_ISR_CAT2 |
ENUMERATION |
CanLoopBackTest_Enable |
Enable/Disable LoopBack test API.If this parameter is set to true the LoopBack mode shall be supported which is used for internal testing. Otherwise the API is not supported. |
TRUE |
TRUE FALSE |
BOOLEAN |
CanMainFunctionReadPeriod |
This parameter describes the period for cyclic call to Can_MainFunction_Read. Unit is seconds. |
0.001 |
0.001..65.535 |
FLOAT |
CanMainFunctionWritePeriod |
This parameter describes the period for cyclic call to Can_MainFunction_Write. Unit is seconds. |
0.001 |
0.001..65.535 |
FLOAT |
CanDeviceVariant |
Select SOC variant .This parameter shall be used by driver to impose device specific constraints. The user guide shall detail the device specific constraints |
AM263Px |
AM263Px |
ENUMERATION |
CanTimeoutDuration |
CanTimeoutDuration parameter Value should be passed as number of ticks according to clock frequency. The clock source have changed from RTI timers which used 200MHz clock frequency to R5f timers which uses 400MHz clock frequency, so the timeout values need to be configured accordingly. |
20 |
0.001..65.535 |
FLOAT |
4.2.9.2. Symbolic Names deviations
None
4.2.9.3. Configuration rules and constraints to enable plausibility checks
None
4.2.9.4. Steps To Configure Can Module
Open EB Tresos configurator tool and load Port, Mcu and Can modules
Open PORT module plugin and configure required pins as CAN-TX, CAN-RX
Open CAN module plugin, Select the Config Variant (Pre-compile/Link-Time)
In CAN module plugin configure required parameters.
Save the configuration and generate the configuration.
4.2.10. Examples
4.2.10.1. Overview
Will be updated in the next release
4.2.10.2. Hardware Software Setup and Tools
PMIC Settings should be initialized for AM263Px CC board.
Locate the CAN-H and CAN-L pins on both the PCAN device and the board. Refer to the documentation or user manual for both the PCAN device and the board to find the correct pins.
Select appropriate cables with the necessary connectors to connect between the PCAN device and the board. Ensure the cables have the correct connectors to fit securely into both the PCAN device and board’s connectors.
Connect the CAN-H pin from the PCAN device to the corresponding CAN-H pin on the board using the chosen cable.
Connect the CAN-L pin from the PCAN device to the corresponding CAN-L pin on the board using the chosen cable.
Place a 120-ohm resistor between the CAN-H and CAN-L lines at the board end.
The resistor should be connected in parallel between the CAN-H and CAN-L lines, creating a termination point.
Open the PCAN configuration software on your PC. The software is usually provided by the manufacturer of the PCAN device.
Locate the settings for bit rate configuration.
Set the nominal bit rate to 1 Mbps and the data bit rate to 5 Mbps.
Apply the changes and save the configuration.
Ensure all connections are secure and properly plugged into their respective connectors on both the PCAN device and the board.
Before powering on the system, double-check all connections to ensure they are correctly made, and there are no loose or improperly connected cables.
After making the connections and configuring the PCAN device, power on both the board and the PCAN device.
Once the system is powered on, verify that the CAN communication is established between the board and the PCAN device.
4.2.10.3. Steps to build and run example
CAN example application demonstrating the MCAL CAN driver features is in folder <MCAL_ROOT>/examples/Can.
This application can be built from the build folder by giving “gmake –s can_app PLATFORM=am263px.”
Once the build is completed we get a binary file, which is loaded in our controller and executed.
4.2.10.4. Flow of the example application
By default, the CAN example runs in Loop Back mode.
For AM263Px:
All 5 CAN Controllers transmit the data and then receive it through the Interrupt Service Routine (ISR).
After receiving the data, it is compared with the transmitted data.
If the received data mismatches the transmitted data, then the application fails.
External Loop back mode can be enabled by setting “CAN_LOOPBACK_ENABLE” in Can_Cfg.h to STD_OFF.
In External Loop Back mode, CAN communication can be tested using the PCAN debugger.
For AM263Px board:
MCAN4 pins are popped out, and MCAN4 is configured with a 1Mbps nominal bit-rate and 5 Mbps data bit-rate.
While running the example code in External Loop back mode:
First, it asks to select the CAN instance, where “f” corresponds to MCAN4.
Then it asks to select the interrupt or polling method.
If interrupts are enabled for the instance in Can_PBcfg.c, then select the interrupt (“i”) method; otherwise, choose the Polling (“p”) method.
After selecting the method, options for transmission and reception will appear.
If the user chooses the transmit option, they are further prompted to select between standard and extended frames.
Selecting the standard option transmits a Standard CAN frame, while choosing the extended option transmits an extended frame to PCAN.
In receive mode, the controller is ready to receive CAN frames from PCAN.
4.2.10.5. Configuration used to test this example
5 Instances of CAN are configured.
All CAN controllers are configured with 1Mbps Arbitration bit rate and 5 Mbps of Data bit rate.
In total 20 Hardware Objects are configured, For each CAN controller 2 HTH and 2 HRH.
In Default example for Reception 0xC1 ID filter is configured for Polling Mode and 0xC0 ID filter is configured for Interrupt mode.
Please refer configuration parameters in below images for baudrate update
For 1Mbps and 5Mpbs:


For 500Kbps and 2.5Mpbs:


4.2.10.6. Example Logs
CanApp: Sample Application - STARTS !!!
CanApp: CAN Loopback test
CanApp: Can Controller: MCAN0
CanAppCalling Can_Write
CanAppCan_Write ok
CanApp: Test Passed
CanApp: Can Controller: MCAN1
CanAppCalling Can_Write
CanAppCan_Write ok
CanApp: Test Passed
CanApp: Can Controller: MCAN2
CanAppCalling Can_Write
CanAppCan_Write ok
CanApp: Test Passed
CanApp: Can Controller: MCAN3
CanAppCalling Can_Write
CanAppCan_Write ok
CanApp: Test Passed
CanApp: Can Controller: MCAN4
CanAppCalling Can_Write
CanAppCan_Write ok
CanApp: Test Passed
CAN Stack Usage: 832 bytes
CAN Test Passed!!!
4.2.10.7. File Structure
📦AM263Px
┣ 📂build
┣ 📂mcal
┃ ┣ 📂examples
┃ ┃ ┣ 📂Can
┃ ┃ ┃ ┣ 📂soc
┃ ┃ ┃ ┣ 📜CanApp.c : Contains CAN test example.
┃ ┃ ┃ ┣ 📜Makefile
┃ ┣ 📂examples_config
┃ ┃ ┣ 📂Can_Demo_Cfg
┃ ┃ ┃ ┣ 📂soc
┃ ┃ ┃ ┃ ┣ 📂am263px
┃ ┃ ┃ ┃ ┃ ┣ 📂r5f0_0
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂include
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Can_Cfg.h : Contains the Precompile switches, Macros for CAN controllers, Hardware Objects etc.
┃ ┃ ┃ ┃ ┃ ┃ ┣ 📂src
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Can_Cfg.c : Contains all controllers Pre-Compile Configuration parameters
┃ ┃ ┃ ┃ ┃ ┃ ┃ ┣ 📜Can_PBcfg.c : Contains all controllers Post-Build Configuration parameters
┃ 📂mcal_config
┃ 📂mcal_docs
┣ 📜README.txt
Note
Can_PBcfg.c and Can_Cfg.c will be present if Post-Build config variant is selected, only Can_Cfg.c will be present if Pre-Compile variant is selected
4.2.11. FAQ’s
4.2.12. Test Report
Please refer AM26x CAN Driver Test Case Report as part of CSP provided in the release package.