Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

To configure a CAN bus interface, a global (optional: const) variable of the type CANBUS_PARA (defined in can_bus.h) must be allocated in the configuration file can_cfg.c, and filled with the corresponding configuration values.

CAN Bus Interface Config

The RX600 CAN Driver will be used as an example to describe the communication parameters required in can_cfg.c.

#include  "can_bus.h"

const  CANBUS_PARA  CanCfg = {                                  /* --------------- CAN BUS CONFIGURATION -------------- */
    CAN_FALSE,                                   [1]            /* EXTENDED FLAG                                        */
    1000000L,                                    [2]            /* BAUDRATE                                             */
    0,                                           [3]            /* BUS NODE                                             */
    0,                                           [4]            /* BUS DEVICE                                           */
                                                 [5]            /* DRIVER FUNCTIONS                                     */
    RX600_CAN_Init,                                             /*      Init                                            */
    RX600_CAN_Open,                                             /*      Open                                            */
    RX600_CAN_Close,                                            /*      Close                                           */
    RX600_CAN_IoCtl,                                            /*      IoCtl                                           */
    RX600_CAN_Read,                                             /*      Read                                            */
    RX600_CAN_Write,                                            /*      Write                                           */
    {                                                           /* DRIVER IO FUNCTION CODES                             */
        IO_RX600_CAN_SET_BAUDRATE,               [6]            /*      Set Baud Rate                                   */
        IO_RX600_CAN_START,                                     /*      Start                                           */
        IO_RX600_CAN_STOP,                                      /*      Stop                                            */
        IO_RX600_CAN_RX_STANDARD,                               /*      Rx Standard                                     */
        IO_RX600_CAN_RX_EXTENDED,                               /*      Rx Extended                                     */
        IO_RX600_CAN_TX_READY,                                  /*      Tx Ready                                        */
        IO_RX600_CAN_GET_NODE_STATUS,                           /*      Get Node Status                                 */
    }
};

      A CAN Bus Configuration

MUST

    be declared global because the configuration data will be used both during initialization and in the CAN Bus Layer. Also, it is done this way to save RAM Space and get a write-protected configuration.

Node & Device Separation

A separation of Bus Node from Device Driver is necessary when different CAN modules are used (i.e. on a processor with integrated CAN module and also external CAN module(s), or with a CAN module with multiple channels).

Example

The MPC565 processor TouCAN has 3 available CAN channles (A, B, C) with the option of also having 3 external SJA1000 CAN modules, having 6 CAN Nodes overall available. However, both the device driver(s) from TouCAN & SJA1000 range from 0-2, and since each CAN node must have it's own unique Bus Node/Driver Device configuration, the following shows a possible configuration of the 6 CAN nodes:

Configuration TouCAN A
Bus node 0
Driver device 0

Configuration TouCAN B
Bus node 1
Driver device 1

Configuration TouCAN C
Bus node 4
Driver device 2

Configuration SJA1000 1
Bus node 5
Driver device 0

Configuration SJA1000 2
Bus node 2
Driver device 1

Configuration SJA1000 3
Bus node 3
Driver device 2

If only one CAN device is used then both the bus node and driver device can be set to equal values.

  • No labels