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

📄 can.c

📁 xc164的双can的使用例程
💻 C
📖 第 1 页 / 共 5 页
字号:
  CAN_MSGDRL14   =  0x0000;      // load data register 4 low
  CAN_MSGDRH14   =  0x0000;      // load data register 4 high

  ///  - functionality of standard message object

  CAN_MSGFGCRL1  =  0x0000;      // load FIFO/gateway control register low
  CAN_MSGFGCRH1  =  0x0001;      // load FIFO/gateway control register high

  CAN_MSGCTRH1   =  0x0000;      // load message control register high
  CAN_MSGCTRL1   =  0x5599;      // load message control register low

  ///  -----------------------------------------------------------------------
  ///  Configuration of Message Object 2:
  ///  -----------------------------------------------------------------------
  ///  - message object 2 is valid
  ///  - enable receive interrupt; bit INTPND is set after successfull 
  ///    reception of a frame

  ///  - message object is used as receive object
  ///  - standard 11-bit identifier
  ///  - 0 valid data bytes
  ///  - this message object works with CAN node A
  ///  - remote monitoring is disabled
  ///  - receive interrupt node pointer: TwinCAN SRN 0

  CAN_MSGCFGL2   =  0x0000;      // load message configuration register low
  CAN_MSGCFGH2   =  0x0000;      // load message configuration register high

  ///  - acceptance mask 11-bit: 0x7FF
  ///  - identifier 11-bit:      0x003

  CAN_MSGAMRL2   =  0xFFFF;      // load acceptance mask register low
  CAN_MSGAMRH2   =  0xFFFF;      // load acceptance mask register high
  CAN_MSGARL2    =  0x0000;      // load arbitration register low
  CAN_MSGARH2    =  0x000C;      // load arbitration register high
  CAN_MSGDRL20   =  0x0000;      // load data register 0 low
  CAN_MSGDRH20   =  0x0000;      // load data register 0 high
  CAN_MSGDRL24   =  0x0000;      // load data register 4 low
  CAN_MSGDRH24   =  0x0000;      // load data register 4 high

  ///  - functionality of standard message object

  CAN_MSGFGCRL2  =  0x0000;      // load FIFO/gateway control register low
  CAN_MSGFGCRH2  =  0x0002;      // load FIFO/gateway control register high

  CAN_MSGCTRH2   =  0x0000;      // load message control register high
  CAN_MSGCTRL2   =  0x5599;      // load message control register low

  ///  -----------------------------------------------------------------------
  ///  Configuration of Message Object 3:
  ///  -----------------------------------------------------------------------
  ///  - message object 3 is valid
  ///  - enable receive interrupt; bit INTPND is set after successfull 
  ///    reception of a frame

  ///  - message object is used as receive object
  ///  - standard 11-bit identifier
  ///  - 0 valid data bytes
  ///  - this message object works with CAN node A
  ///  - remote monitoring is disabled
  ///  - receive interrupt node pointer: TwinCAN SRN 0

  CAN_MSGCFGL3   =  0x0000;      // load message configuration register low
  CAN_MSGCFGH3   =  0x0000;      // load message configuration register high

  ///  - acceptance mask 11-bit: 0x7FF
  ///  - identifier 11-bit:      0x234

  CAN_MSGAMRL3   =  0xFFFF;      // load acceptance mask register low
  CAN_MSGAMRH3   =  0xFFFF;      // load acceptance mask register high
  CAN_MSGARL3    =  0x0000;      // load arbitration register low
  CAN_MSGARH3    =  0x08D0;      // load arbitration register high
  CAN_MSGDRL30   =  0x0000;      // load data register 0 low
  CAN_MSGDRH30   =  0x0000;      // load data register 0 high
  CAN_MSGDRL34   =  0x0000;      // load data register 4 low
  CAN_MSGDRH34   =  0x0000;      // load data register 4 high

  ///  - functionality of standard message object

  CAN_MSGFGCRL3  =  0x0000;      // load FIFO/gateway control register low
  CAN_MSGFGCRH3  =  0x0003;      // load FIFO/gateway control register high

  CAN_MSGCTRH3   =  0x0000;      // load message control register high
  CAN_MSGCTRL3   =  0x5599;      // load message control register low

  ///  -----------------------------------------------------------------------
  ///  Configuration of Message Object 4:
  ///  -----------------------------------------------------------------------
  ///  - message object 4 is valid
  ///  - enable receive interrupt; bit INTPND is set after successfull 
  ///    reception of a frame

  ///  - message object is used as receive object
  ///  - standard 11-bit identifier
  ///  - 0 valid data bytes
  ///  - this message object works with CAN node A
  ///  - remote monitoring is disabled
  ///  - receive interrupt node pointer: TwinCAN SRN 0

  CAN_MSGCFGL4   =  0x0000;      // load message configuration register low
  CAN_MSGCFGH4   =  0x0000;      // load message configuration register high

  ///  - acceptance mask 11-bit: 0x7FF
  ///  - identifier 11-bit:      0x000

  CAN_MSGAMRL4   =  0xFFFF;      // load acceptance mask register low
  CAN_MSGAMRH4   =  0xFFFF;      // load acceptance mask register high
  CAN_MSGARL4    =  0x0000;      // load arbitration register low
  CAN_MSGARH4    =  0x0000;      // load arbitration register high
  CAN_MSGDRL40   =  0x0000;      // load data register 0 low
  CAN_MSGDRH40   =  0x0000;      // load data register 0 high
  CAN_MSGDRL44   =  0x0000;      // load data register 4 low
  CAN_MSGDRH44   =  0x0000;      // load data register 4 high

  ///  - functionality of standard message object

  CAN_MSGFGCRL4  =  0x0000;      // load FIFO/gateway control register low
  CAN_MSGFGCRH4  =  0x0004;      // load FIFO/gateway control register high

  CAN_MSGCTRH4   =  0x0000;      // load message control register high
  CAN_MSGCTRL4   =  0x5599;      // load message control register low

  ///  -----------------------------------------------------------------------
  ///  Configuration of Message Object 5:
  ///  -----------------------------------------------------------------------
  ///  - message object 5 is valid
  ///  - enable receive interrupt; bit INTPND is set after successfull 
  ///    reception of a frame

  ///  - message object is used as receive object
  ///  - standard 11-bit identifier
  ///  - 0 valid data bytes
  ///  - this message object works with CAN node A
  ///  - remote monitoring is disabled
  ///  - receive interrupt node pointer: TwinCAN SRN 0

  CAN_MSGCFGL5   =  0x0000;      // load message configuration register low
  CAN_MSGCFGH5   =  0x0000;      // load message configuration register high

  ///  - acceptance mask 11-bit: 0x7FF
  ///  - identifier 11-bit:      0x006

  CAN_MSGAMRL5   =  0xFFFF;      // load acceptance mask register low
  CAN_MSGAMRH5   =  0xFFFF;      // load acceptance mask register high
  CAN_MSGARL5    =  0x0000;      // load arbitration register low
  CAN_MSGARH5    =  0x0018;      // load arbitration register high
  CAN_MSGDRL50   =  0x0000;      // load data register 0 low
  CAN_MSGDRH50   =  0x0000;      // load data register 0 high
  CAN_MSGDRL54   =  0x0000;      // load data register 4 low
  CAN_MSGDRH54   =  0x0000;      // load data register 4 high

  ///  - functionality of standard message object

  CAN_MSGFGCRL5  =  0x0000;      // load FIFO/gateway control register low
  CAN_MSGFGCRH5  =  0x0005;      // load FIFO/gateway control register high

  CAN_MSGCTRH5   =  0x0000;      // load message control register high
  CAN_MSGCTRL5   =  0x5599;      // load message control register low

  ///  -----------------------------------------------------------------------
  ///  Configuration of Message Object 6:
  ///  -----------------------------------------------------------------------
  ///  - message object 6 is valid
  ///  - enable receive interrupt; bit INTPND is set after successfull 
  ///    reception of a frame

  ///  - message object is used as receive object
  ///  - standard 11-bit identifier
  ///  - 0 valid data bytes
  ///  - this message object works with CAN node A
  ///  - remote monitoring is disabled
  ///  - receive interrupt node pointer: TwinCAN SRN 0

  CAN_MSGCFGL6   =  0x0000;      // load message configuration register low
  CAN_MSGCFGH6   =  0x0000;      // load message configuration register high

  ///  - acceptance mask 11-bit: 0x7FF
  ///  - identifier 11-bit:      0x007

  CAN_MSGAMRL6   =  0xFFFF;      // load acceptance mask register low
  CAN_MSGAMRH6   =  0xFFFF;      // load acceptance mask register high
  CAN_MSGARL6    =  0x0000;      // load arbitration register low
  CAN_MSGARH6    =  0x001C;      // load arbitration register high
  CAN_MSGDRL60   =  0x0000;      // load data register 0 low
  CAN_MSGDRH60   =  0x0000;      // load data register 0 high
  CAN_MSGDRL64   =  0x0000;      // load data register 4 low
  CAN_MSGDRH64   =  0x0000;      // load data register 4 high

  ///  - functionality of standard message object

  CAN_MSGFGCRL6  =  0x0000;      // load FIFO/gateway control register low
  CAN_MSGFGCRH6  =  0x0006;      // load FIFO/gateway control register high

  CAN_MSGCTRH6   =  0x0000;      // load message control register high
  CAN_MSGCTRL6   =  0x5599;      // load message control register low

  ///  -----------------------------------------------------------------------
  ///  Configuration of Message Object 7:
  ///  -----------------------------------------------------------------------
  ///  - message object 7 is valid
  ///  - enable receive interrupt; bit INTPND is set after successfull 
  ///    reception of a frame

  ///  - message object is used as receive object
  ///  - standard 11-bit identifier
  ///  - 0 valid data bytes
  ///  - this message object works with CAN node A
  ///  - remote monitoring is disabled
  ///  - receive interrupt node pointer: TwinCAN SRN 0

  CAN_MSGCFGL7   =  0x0000;      // load message configuration register low
  CAN_MSGCFGH7   =  0x0000;      // load message configuration register high

  ///  - acceptance mask 11-bit: 0x7FF
  ///  - identifier 11-bit:      0x008

  CAN_MSGAMRL7   =  0xFFFF;      // load acceptance mask register low
  CAN_MSGAMRH7   =  0xFFFF;      // load acceptance mask register high
  CAN_MSGARL7    =  0x0000;      // load arbitration register low
  CAN_MSGARH7    =  0x0020;      // load arbitration register high
  CAN_MSGDRL70   =  0x0000;      // load data register 0 low
  CAN_MSGDRH70   =  0x0000;      // load data register 0 high
  CAN_MSGDRL74   =  0x0000;      // load data register 4 low
  CAN_MSGDRH74   =  0x0000;      // load data register 4 high

  ///  - functionality of standard message object

  CAN_MSGFGCRL7  =  0x0000;      // load FIFO/gateway control register low
  CAN_MSGFGCRH7  =  0x0007;      // load FIFO/gateway control register high

  CAN_MSGCTRH7   =  0x0000;      // load message control register high
  CAN_MSGCTRL7   =  0x5599;      // load message control register low

  ///  -----------------------------------------------------------------------
  ///  Configuration of Message Object 8:
  ///  -----------------------------------------------------------------------
  ///  - message object 8 is valid
  ///  - enable receive interrupt; bit INTPND is set after successfull 
  ///    reception of a frame

  ///  - message object is used as receive object
  ///  - standard 11-bit identifier
  ///  - 0 valid data bytes
  ///  - this message object works with CAN node A
  ///  - remote monitoring is disabled
  ///  - receive interrupt node pointer: TwinCAN SRN 0

  CAN_MSGCFGL8   =  0x0000;      // load message configuration register low
  CAN_MSGCFGH8   =  0x0000;      // load message configuration register high

  ///  - acceptance mask 11-bit: 0x7FF
  ///  - identifier 11-bit:      0x009

  CAN_MSGAMRL8   =  0xFFFF;      // load acceptance mask register low
  CAN_MSGAMRH8   =  0xFFFF;      // load acceptance mask register high
  CAN_MSGARL8    =  0x0000;      // load arbitration register low
  CAN_MSGARH8    =  0x0024;      // load arbitration register high
  CAN_MSGDRL80   =  0x0000;      // load data register 0 low
  CAN_MSGDRH80   =  0x0000;      // load data register 0 high
  CAN_MSGDRL84   =  0x0000;      // load data register 4 low
  CAN_MSGDRH84   =  0x0000;      // load data register 4 high

  ///  - functionality of standard message object

  CAN_MSGFGCRL8  =  0x0000;      // load FIFO/gateway control register low
  CAN_MSGFGCRH8  =  0x0008;      // load FIFO/gateway control register high

  CAN_MSGCTRH8   =  0x0000;      // load message control register high
  CAN_MSGCTRL8   =  0x5599;      // load message control register low

  ///  -----------------------------------------------------------------------
  ///  Configuration of Message Object 9:
  ///  -----------------------------------------------------------------------
  ///  - message object 9 is valid
  ///  - enable receive interrupt; bit INTPND is set after successfull 
  ///    reception of a frame

  ///  - message object is used as receive object
  ///  - standard 11-bit identifier
  ///  - 0 valid data bytes
  ///  - this message object works with CAN node A
  ///  - remote monitoring is disabled
  ///  - receive interrupt node pointer: TwinCAN SRN 0

  CAN_MSGCFGL9   =  0x0000;      // load message configuration register low
  CAN_MSGCFGH9   =  0x0000;      // load message configuration register high

  ///  - acceptance mask 11-bit: 0x7FF
  ///  - identifier 11-bit:      0x000

  CAN_MSGAMRL9   =  0xFFFF;      // load acceptance mask register low
  CAN_MSGAMRH9   =  0xFFFF;      // load acceptance mask register high
  CAN_MSGARL9    =  0x0000;      // load arbitration register low
  CAN_MSGARH9    =  0x0000;      // load arbitration register high
  CAN_MSGDRL90   =  0x0000;      // load data register 0 low
  CAN_MSGDRH90   =  0x0000;      // load data register 0 high

⌨️ 快捷键说明

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