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

📄 can.lst

📁 英飞凌C166之XC164CS双CAN通讯程序
💻 LST
📖 第 1 页 / 共 3 页
字号:
C166 COMPILER V6.04, CAN                                                                   09/08/2007 14:27:20 PAGE 1   


C166 COMPILER V6.04, COMPILATION OF MODULE CAN
OBJECT MODULE PLACED IN CAN.OBJ
COMPILER INVOKED BY: E:\program files\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       TwinCAN.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          2007-5-25 16:53:14
   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                                                                   09/08/2007 14:27:20 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                                                                   09/08/2007 14:27:20 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          2007-5-25
  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 = 250.000 kbaud
  176  1        ///  - real baud rate     = 250.000 kbaud
  177  1        ///  - sample point       = 60.00 %
  178  1        ///  - there are 5 time quanta before sample point
  179  1        ///  - there are 4 time quanta after sample point
C166 COMPILER V6.04, CAN                                                                   09/08/2007 14:27:20 PAGE 4   

  180  1        ///  - the (re)synchronization jump width is 2 time quanta
  181  1      
  182  1        CAN_ABTRL      =  0x3447;      // 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        ///  - enable interrupt generation when a message transfer is completed
  197  1        ///  - transmit / receive OK interrupt node pointer: TwinCAN SRN 1
  198  1      
  199  1        CAN_BCR        =  0x0045;      // load global control register
  200  1        CAN_BGINP      =  0x0100;      // load global interrupt node pointer 
  201  1                                       // register
  202  1      
  203  1        ///  Configuration of the Node B Error Counter:
  204  1        ///  - the error warning threshold value (warning level) is 96
  205  1      
  206  1        CAN_BECNTH     =  0x0060;      // load error counter register high
  207  1      
  208  1        ///  Configuration of the used CAN Port Pins:
  209  1        ///  - P4.4 is used for CAN Interface Input (RXDCB)
  210  1        ///  - P4.7 is used for CAN Interface Output (TXDCB)
  211  1      
  212  1        ALTSEL0P4     |=  0x0080;      // select alternate output function
  213  1        DP4  = (DP4  & ~(uword)0x0080) | 0x0080;    //set direction register
  214  1      
  215  1        ///  Configuration of the Node B Baud Rate:
  216  1        ///  - required baud rate = 250.000 kbaud
  217  1        ///  - real baud rate     = 250.000 kbaud
  218  1        ///  - sample point       = 60.00 %
  219  1        ///  - there are 5 time quanta before sample point
  220  1        ///  - there are 4 time quanta after sample point
  221  1        ///  - the (re)synchronization jump width is 2 time quanta
  222  1      
  223  1        CAN_BBTRL      =  0x3447;      // load bit timing register low
  224  1      
  225  1        CAN_BBTRH      =  0x0000;      // load bit timing register high
  226  1      
  227  1        CAN_BFCRL      =  0x0000;      // load frame counter timing register low
  228  1      
  229  1        CAN_BFCRH      =  0x0000;      // load frame counter timing register high
  230  1      
  231  1        ///  -----------------------------------------------------------------------
  232  1        ///  Configuration of the CAN Message Objects 0 - 31:
  233  1        ///  -----------------------------------------------------------------------
  234  1      
  235  1        ///  -----------------------------------------------------------------------
  236  1        ///  Configuration of Message Object 0:
  237  1        ///  -----------------------------------------------------------------------
  238  1        ///  - message object 0 is valid
  239  1        ///  - enable transmit interrupt; bit INTPND is set after successfull 
  240  1        ///    transmission of a frame
  241  1      
C166 COMPILER V6.04, CAN                                                                   09/08/2007 14:27:20 PAGE 5   

  242  1        ///  - message object is used as transmit object
  243  1        ///  - standard 11-bit identifier
  244  1        ///  - 8 valid data bytes
  245  1        ///  - this message object works with CAN node A
  246  1        ///  - remote monitoring is disabled
  247  1        ///  - transmit interrupt node pointer: TwinCAN SRN 0
  248  1      
  249  1        CAN_MSGCFGL0   =  0x0088;      // load message configuration register low
  250  1        CAN_MSGCFGH0   =  0x0000;      // load message configuration register high
  251  1      
  252  1        ///  - acceptance mask 11-bit: 0x7FF
  253  1        ///  - identifier 11-bit:      0x123
  254  1      
  255  1        CAN_MSGAMRL0   =  0xFFFF;      // load acceptance mask register low
  256  1        CAN_MSGAMRH0   =  0xFFFF;      // load acceptance mask register high
  257  1        CAN_MSGARL0    =  0x0000;      // load arbitration register low
  258  1        CAN_MSGARH0    =  0x048C;      // load arbitration register high
  259  1        CAN_MSGDRL00   =  0x0100;      // load data register 0 low
  260  1        CAN_MSGDRH00   =  0x0302;      // load data register 0 high
  261  1        CAN_MSGDRL04   =  0x0504;      // load data register 4 low
  262  1        CAN_MSGDRH04   =  0x0706;      // load data register 4 high
  263  1      
  264  1        ///  - functionality of standard message object
  265  1      
  266  1        CAN_MSGFGCRL0  =  0x0000;      // load FIFO/gateway control register low
  267  1        CAN_MSGFGCRH0  =  0x0000;      // load FIFO/gateway control register high
  268  1      
  269  1        CAN_MSGCTRH0   =  0x0000;      // load message control register high
  270  1        CAN_MSGCTRL0   =  0x55A5;      // load message control register low
  271  1      
  272  1        ///  -----------------------------------------------------------------------
  273  1        ///  Configuration of Message Object 1:
  274  1        ///  -----------------------------------------------------------------------
  275  1        ///  - message object 1 is valid
  276  1        ///  - enable receive interrupt; bit INTPND is set after successfull 
  277  1        ///    reception of a frame
  278  1      
  279  1        ///  - message object is used as receive object
  280  1        ///  - standard 11-bit identifier
  281  1        ///  - 8 valid data bytes
  282  1        ///  - this message object works with CAN node B
  283  1        ///  - remote monitoring is disabled
  284  1        ///  - receive interrupt node pointer: TwinCAN SRN 1
  285  1      
  286  1        CAN_MSGCFGL1   =  0x0082;      // load message configuration register low
  287  1        CAN_MSGCFGH1   =  0x0001;      // load message configuration register high
  288  1      
  289  1        ///  - acceptance mask 11-bit: 0x7FF
  290  1        ///  - identifier 11-bit:      0x123
  291  1      
  292  1        CAN_MSGAMRL1   =  0xFFFF;      // load acceptance mask register low
  293  1        CAN_MSGAMRH1   =  0xFFFF;      // load acceptance mask register high
  294  1        CAN_MSGARL1    =  0x0000;      // load arbitration register low
  295  1        CAN_MSGARH1    =  0x048C;      // load arbitration register high
  296  1        CAN_MSGDRL10   =  0x0000;      // load data register 0 low
  297  1        CAN_MSGDRH10   =  0x0000;      // load data register 0 high
  298  1        CAN_MSGDRL14   =  0x0000;      // load data register 4 low

⌨️ 快捷键说明

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