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

📄 can.lst

📁 开发环境为keil166
💻 LST
📖 第 1 页 / 共 3 页
字号:
C166 COMPILER V6.04, CAN                                                                   04/06/2009 22:15: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_configure.dav
    5         //----------------------------------------------------------------------------
    6         // @Controller    Infineon XC164CS-16F20
    7         //
    8         // @Compiler      Keil
    9         //
   10         // @Codegenerator 2.8
   11         //
   12         // @Description   This file contains functions that use the CAN module.
   13         //
   14         //----------------------------------------------------------------------------
   15         // @Date          2009-4-4 17:03:47
   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                                                                   04/06/2009 22:15: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                                                                   04/06/2009 22:15: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          2009-4-4
  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        ///  - enable interrupt generation when a message transfer is completed
  156  1        ///  - transmit / receive OK interrupt node pointer: TwinCAN SRN 0
  157  1      
  158  1        CAN_ACR        =  0x0045;      // load global control register
  159  1        CAN_AGINP      =  0x0000;      // load global interrupt node pointer 
  160  1                                       // register
  161  1      
  162  1        ///  Configuration of the Node A Error Counter:
  163  1        ///  - the error warning threshold value (warning level) is 96
  164  1      
  165  1        CAN_AECNTH     =  0x0060;      // load error counter register high
  166  1      
  167  1        ///  Configuration of the used CAN Port Pins:
  168  1        ///  - P4.5 is used for CAN Interface Input (RXDCA)
  169  1        ///  - P4.6 is used for CAN Interface Output (TXDCA)
  170  1      
  171  1        ALTSEL0P4     |=  0x0040;      // select alternate output function
  172  1        DP4  = (DP4  & ~(uword)0x0040) | 0x0040;    //set direction register
  173  1      
  174  1        ///  Configuration of the Node A Baud Rate:
  175  1        ///  - required baud rate = 500.000 kbaud
  176  1        ///  - real baud rate     = 500.000 kbaud
  177  1        ///  - sample point       = 70.00 %
  178  1        ///  - there are 6 time quanta before sample point
  179  1        ///  - there are 3 time quanta after sample point
C166 COMPILER V6.04, CAN                                                                   04/06/2009 22:15:28 PAGE 4   

  180  1        ///  - the (re)synchronization jump width is 2 time quanta
  181  1      
  182  1        CAN_ABTRL      =  0x2543;      // load bit timing register low
  183  1      
  184  1        CAN_ABTRH      =  0x0000;      // load bit timing register high
  185  1      
  186  1        CAN_AFCRL      =  0x0000;      // load frame counter timing register low
  187  1      
  188  1        CAN_AFCRH      =  0x0000;      // load frame counter timing register high
  189  1      
  190  1        ///  -----------------------------------------------------------------------
  191  1        ///  Configuration of CAN Node B:
  192  1        ///  -----------------------------------------------------------------------
  193  1      
  194  1        ///  General Configuration of the Node B:
  195  1        ///  - set INIT and CCE
  196  1      
  197  1        CAN_BCR        =  0x0041;      // load global control register
  198  1      
  199  1        ///  -----------------------------------------------------------------------
  200  1        ///  Configuration of the CAN Message Objects 0 - 31:
  201  1        ///  -----------------------------------------------------------------------
  202  1      
  203  1        ///  -----------------------------------------------------------------------
  204  1        ///  Configuration of Message Object 0:
  205  1        ///  -----------------------------------------------------------------------
  206  1        ///  - message object 0 is valid
  207  1        ///  - enable receive interrupt; bit INTPND is set after successfull 
  208  1        ///    reception of a frame
  209  1      
  210  1        ///  - message object is used as receive object
  211  1        ///  - standard 11-bit identifier

⌨️ 快捷键说明

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