⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 can.lst

📁 本程序是针对Infineon公司的XC167CI处理器而编写的CAN网络程序。CAN(控制局域网)协议是一种广泛的应用于汽车电子的网络协议。本程序建立了三个CAN节点
💻 LST
📖 第 1 页 / 共 4 页
字号:
C166 COMPILER V6.04, CAN                                                                   12/10/2006 20:50:28 PAGE 1   


C166 COMPILER V6.04, COMPILATION OF MODULE CAN
OBJECT MODULE PLACED IN CAN.OBJ
COMPILER INVOKED BY: C:\Keil\C166\BIN\C166.EXE CAN.C MODV2 BROWSE MODV2 DEBUG

 stmt lvl     source

    1         //****************************************************************************
    2         // @Module        TwinCAN Module (CAN)
    3         // @Filename      CAN.C
    4         // @Project       can.dav
    5         //----------------------------------------------------------------------------
    6         // @Controller    Infineon XC167CI-32F20
    7         //
    8         // @Compiler      Keil
    9         //
   10         // @Codegenerator 2.4
   11         //
   12         // @Description   This file contains functions that use the CAN module.
   13         //
   14         //----------------------------------------------------------------------------
   15         // @Date          2006-12-10 17:27:22
   16         //
   17         //****************************************************************************
   18         
   19         // USER CODE BEGIN (CAN_General,1)
   20         
   21         // USER CODE END
   22         
   23         
   24         
   25         //****************************************************************************
   26         // @Project Includes
   27         //****************************************************************************
   28         
   29         #include "MAIN.H"
   30         
   31         // USER CODE BEGIN (CAN_General,2)
   32         
   33         // USER CODE END
   34         
   35         
   36         //****************************************************************************
   37         // @Macros
   38         //****************************************************************************
   39         
   40         // USER CODE BEGIN (CAN_General,3)
   41         
   42         // USER CODE END
   43         
   44         
   45         //****************************************************************************
   46         // @Defines
   47         //****************************************************************************
   48         
   49         // Structure for a single TwinCAN object
   50         // A total of 31 such object structures exists
   51         
   52         struct stCanObj 
   53         {
   54           ubyte  ubData[8];  // Message Data 0..7
   55           ulong  ulCANAR;    // Arbitration Register
C166 COMPILER V6.04, CAN                                                                   12/10/2006 20:50:28 PAGE 2   

   56           ulong  ulCANAMR;   // Acceptance Mask Register
   57           uword  uwMSGCTR;   // Message Control Register
   58           uword  uwCounter;  // Frame Counter
   59           uword  uwMSGCFG;   // Message Configuration Register
   60           uword  uwINP;      // Interrupt Node Pointer
   61           uword  uwCANFCR;   // FIFO / Gateway Control Register 
   62           uword  uwCANPTR;   // FIFO Pointer
   63           ulong  ulReserved; // Reserved
   64         };
   65         
   66         #define CAN_HWOBJ ((struct stCanObj volatile far *) 0x200300)
   67         
   68         // USER CODE BEGIN (CAN_General,4)
   69         
   70         // USER CODE END
   71         
   72         
   73         //****************************************************************************
   74         // @Typedefs
   75         //****************************************************************************
   76         
   77         // USER CODE BEGIN (CAN_General,5)
   78         
   79         // USER CODE END
   80         
   81         
   82         //****************************************************************************
   83         // @Imported Global Variables
   84         //****************************************************************************
   85         
   86         // USER CODE BEGIN (CAN_General,6)
   87         
   88         // USER CODE END
   89         
   90         
   91         //****************************************************************************
   92         // @Global Variables
   93         //****************************************************************************
   94         
   95         
   96         // USER CODE BEGIN (CAN_General,7)
   97         
   98         // USER CODE END
   99         
  100         
  101         //****************************************************************************
  102         // @External Prototypes
  103         //****************************************************************************
  104         
  105         // USER CODE BEGIN (CAN_General,8)
  106         
  107         // USER CODE END
  108         
  109         
  110         //****************************************************************************
  111         // @Prototypes Of Local Functions
  112         //****************************************************************************
  113         
  114         // USER CODE BEGIN (CAN_General,9)
  115         
  116         // USER CODE END
  117         
C166 COMPILER V6.04, CAN                                                                   12/10/2006 20:50:28 PAGE 3   

  118         
  119         //****************************************************************************
  120         // @Function      void CAN_vInit(void) 
  121         //
  122         //----------------------------------------------------------------------------
  123         // @Description   This is the initialization function of the CAN function 
  124         //                library. It is assumed that the SFRs used by this library 
  125         //                are in its reset state. 
  126         //
  127         //----------------------------------------------------------------------------
  128         // @Returnvalue   None
  129         //
  130         //----------------------------------------------------------------------------
  131         // @Parameters    None
  132         //
  133         //----------------------------------------------------------------------------
  134         // @Date          2006-12-10
  135         //
  136         //****************************************************************************
  137         
  138         // USER CODE BEGIN (Init,1)
  139         
  140         // USER CODE END
  141         
  142         void CAN_vInit(void)
  143         {
  144  1      
  145  1        // USER CODE BEGIN (Init,2)
  146  1      
  147  1        // USER CODE END
  148  1      
  149  1        ///  -----------------------------------------------------------------------
  150  1        ///  Configuration of CAN Node A:
  151  1        ///  -----------------------------------------------------------------------
  152  1      
  153  1        ///  General Configuration of the Node A:
  154  1        ///  - set INIT and CCE
  155  1      
  156  1        CAN_ACR        =  0x0041;      // load global control register
  157  1      
  158  1        ///  -----------------------------------------------------------------------
  159  1        ///  Configuration of CAN Node B:
  160  1        ///  -----------------------------------------------------------------------
  161  1      
  162  1        ///  General Configuration of the Node B:
  163  1        ///  - set INIT and CCE
  164  1        ///  - enable interrupt generation when a message transfer is completed
  165  1        ///  - transmit / receive OK interrupt node pointer: TwinCAN SRN 0
  166  1      
  167  1        CAN_BCR        =  0x0045;      // load global control register
  168  1        CAN_BGINP      =  0x0000;      // load global interrupt node pointer 
  169  1                                       // register
  170  1      
  171  1        ///  Configuration of the Node B Error Counter:
  172  1        ///  - the error warning threshold value (warning level) is 96
  173  1      
  174  1        CAN_BECNTH     =  0x0060;      // load error counter register high
  175  1      
  176  1        ///  Configuration of the used CAN Port Pins:
  177  1        ///  - P9.0 is used for CAN Interface Input (RXDCB)
  178  1        ///  - P9.1 is used for CAN Interface Output (TXDCB)
  179  1      
C166 COMPILER V6.04, CAN                                                                   12/10/2006 20:50:28 PAGE 4   

  180  1        ALTSEL0P9     |=  0x0002;      // select alternate output function
  181  1        ALTSEL1P9     |=  0x0002;      // select alternate output function
  182  1        DP9  = (DP9  & ~(uword)0x0002) | 0x0002;    //set direction register
  183  1      
  184  1        ///  Configuration of the Node B Baud Rate:
  185  1        ///  - required baud rate = 100.000 kbaud
  186  1        ///  - real baud rate     = 100.000 kbaud
  187  1        ///  - sample point       = 60.00 %
  188  1        ///  - there are 5 time quanta before sample point
  189  1        ///  - there are 4 time quanta after sample point
  190  1        ///  - the (re)synchronization jump width is 2 time quanta
  191  1      
  192  1        CAN_BBTRL      =  0x3453;      // load bit timing register low
  193  1      
  194  1        CAN_BBTRH      =  0x0000;      // load bit timing register high
  195  1      
  196  1        CAN_BFCRL      =  0x0000;      // load frame counter timing register low
  197  1      
  198  1        CAN_BFCRH      =  0x0000;      // load frame counter timing register high
  199  1      
  200  1        ///  -----------------------------------------------------------------------
  201  1        ///  Configuration of the CAN Message Objects 0 - 31:
  202  1        ///  -----------------------------------------------------------------------
  203  1      
  204  1        ///  -----------------------------------------------------------------------
  205  1        ///  Configuration of Message Object 0:
  206  1        ///  -----------------------------------------------------------------------
  207  1        ///  - message object 0 is valid
  208  1        ///  - enable receive interrupt; bit INTPND is set after successfull 
  209  1        ///    reception of a frame
  210  1      
  211  1        ///  - message object is used as receive object
  212  1        ///  - standard 11-bit identifier
  213  1        ///  - 8 valid data bytes
  214  1        ///  - this message object works with CAN node B
  215  1        ///  - remote monitoring is disabled
  216  1        ///  - receive interrupt node pointer: TwinCAN SRN 0
  217  1      
  218  1        CAN_MSGCFGL0   =  0x0082;      // load message configuration register low
  219  1        CAN_MSGCFGH0   =  0x0000;      // load message configuration register high
  220  1      
  221  1        ///  - acceptance mask 11-bit: 0x7FF
  222  1        ///  - identifier 11-bit:      0x133
  223  1      
  224  1        CAN_MSGAMRL0   =  0xFFFF;      // load acceptance mask register low
  225  1        CAN_MSGAMRH0   =  0xFFFF;      // load acceptance mask register high
  226  1        CAN_MSGARL0    =  0x0000;      // load arbitration register low
  227  1        CAN_MSGARH0    =  0x04CC;      // load arbitration register high
  228  1        CAN_MSGDRL00   =  0x0000;      // load data register 0 low
  229  1        CAN_MSGDRH00   =  0x0000;      // load data register 0 high
  230  1        CAN_MSGDRL04   =  0x0000;      // load data register 4 low
  231  1        CAN_MSGDRH04   =  0x0000;      // load data register 4 high
  232  1      
  233  1        ///  - functionality of standard message object
  234  1      
  235  1        CAN_MSGFGCRL0  =  0x0000;      // load FIFO/gateway control register low
  236  1        CAN_MSGFGCRH0  =  0x0000;      // load FIFO/gateway control register high
  237  1      
  238  1        CAN_MSGCTRH0   =  0x0000;      // load message control register high
  239  1        CAN_MSGCTRL0   =  0x5599;      // load message control register low
  240  1      
  241  1        ///  -----------------------------------------------------------------------
C166 COMPILER V6.04, CAN                                                                   12/10/2006 20:50:28 PAGE 5   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -