Difference between revisions of "Component: CAN (Internal, MCP2515) (Comms: Interface)"

From Flowcode Help
Jump to navigationJump to search
(XML import)
Line 1: Line 1:
 
+
{| style="width:50%"
 
 
{| width="50%"
 
 
|-
 
|-
| width="20%" style="color: gray;" | Author
+
| width="20%" style="color:gray;" | Author
 
| Matrix Ltd
 
| Matrix Ltd
 
|-
 
|-
| width="20%" style="color: gray;" | Version
+
| width="20%" style="color:gray;" | Version
| 2.1 (Release)
+
| 2.9
 
|-
 
|-
| width="20%" style="color: gray;" | Category
+
| width="20%" style="color:gray;" | Category
 
| Comms: Interface
 
| Comms: Interface
 
|}
 
|}
  
  
 +
==CAN (Internal, MCP2515) component==
 +
Low level routines for controling the CAN interface either using an external MCP2515 IC and a SPI bus connection or using an internal CAN peripheral if available on your device. Both methods will require a CAN driver IC  like the MCP2551 to drive the CAN signals on the bus.
  
==[[File:Component Icon da332928_6342_4c2c_afc7_eaf33917d33e.png|Image]] CAN (Internal, MCP2515) component==
+
==Detailed description==
Low level routines for controling the CAN interface either using an external MCP2515 IC and a SPI bus connection
+
 
or using an internal CAN peripheral if available on your device. Both methods will require a CAN driver IC
+
''No detailed description exists yet for this component''
like the MCP2551 to drive the CAN signals on the bus.
 
  
 
==Examples==
 
==Examples==
 +
 +
 
===Internal CAN schematic===
 
===Internal CAN schematic===
  
Line 192: Line 193:
 
==Downloadable macro reference==
 
==Downloadable macro reference==
  
===<span style="font-weight: normal;"><u><tt>ReadSwitches</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Returns switch input states from the external MCP2515 device.
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ReadSwitches'''
 +
|-
 +
| colspan="2" | Returns switch input states from the external MCP2515 device. 0 = No Switch Pressed, 1 = Switch 1 Pressed, 2 = Switch 2 Pressed, 3 = Both Pressed (External CAN only) &nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
0 = No Switch Pressed, 1 = Switch 1 Pressed, 2 = Switch 2 Pressed, 3 = Both Pressed
 
  
(External CAN only)
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTxData'''
 +
|-
 +
| colspan="2" | Assigns one of the outgoing transmit buffers with data ready to be sent.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Count
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | d0
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | d1
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | d2
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | d3
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | d4
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | d5
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | d6
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | d7
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
'''Parameters'''
 
  
:''This macro has no parameters''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetRxMask'''
 +
|-
 +
| colspan="2" | Allows the receive ID mask to be configured on the fly allowing different ID ranges to be received.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Mask
 +
|-
 +
| colspan="2" | Specifies which receive mask to modify. Range: 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 +
| width="90%" | ID
 +
|-
 +
| colspan="2" | The ID mask value you wish to use&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
'''Return value'''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRxData'''
 +
|-
 +
| colspan="2" | Returns last received message data byte at position Index. Buffer parameter is currently ignored&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Index
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|BYTE]]
 
  
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRxIDHi'''
 +
|-
 +
| colspan="2" | Gets the Hi byte Rx ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous, &nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | Receive Buffer. Range 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>SetTxData</tt></u></span>===
 
Assigns one of the outgoing transmit buffers with data ready to be sent.
 
  
'''Parameters'''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTxIDSimple'''
 +
|-
 +
| colspan="2" | Set the Tx CAN ID as a generic number. Standard IDs only 0-2047. &nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | Transmit buffer to load. Range: 0-2&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | ID
 +
|-
 +
| colspan="2" | The ID value you wish to use. Range: 0-2047&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|BYTE]] ''Buffer''
 
  
:[[Variable Types|BYTE]] ''Count''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendBuffer'''
 +
|-
 +
| colspan="2" | Transmits one of the transmit buffers which should have already been populated with an ID and data.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | Specifies which transmit buffer to send&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|BYTE]] ''d0''
 
  
:[[Variable Types|BYTE]] ''d1''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRxDataCount'''
 +
|-
 +
| colspan="2" | Returns last received message data length. Buffer parameter is currently ignored&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|BYTE]] ''d2''
 
  
:[[Variable Types|BYTE]] ''d3''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetRxFilterID'''
 +
|-
 +
| colspan="2" | sets the Filter Standard mode only  (for V5 compatibility only)&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Filter
 +
|-
 +
| colspan="2" | Specifies which filter to modify. Range: 0-5&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Hi
 +
|-
 +
| colspan="2" | ID bits 3-10&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Lo
 +
|-
 +
| colspan="2" | ID bits 0-2 stored in the upper 3 bits of the byte&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|BYTE]] ''d4''
 
  
:[[Variable Types|BYTE]] ''d5''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRxIDLo'''
 +
|-
 +
| colspan="2" | Gets the Lo byte Rx ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous, &nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|BYTE]] ''d6''
 
  
:[[Variable Types|BYTE]] ''d7''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetRxMaskID'''
 +
|-
 +
| colspan="2" | set the Mask Standard ID mode only (for V5 compatibility) &nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Mask
 +
|-
 +
| colspan="2" | Specifies which receive mask to modify. Range: 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Hi
 +
|-
 +
| colspan="2" | ID bits 3-10&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Lo
 +
|-
 +
| colspan="2" | ID bits 0-2 stored in the upper 3 bits of the byte&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
'''Return value'''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetRxFilter'''
 +
|-
 +
| colspan="2" | Allows the receive ID filter to be configured on the fly allowing different ID ranges to be received.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Filter
 +
|-
 +
| colspan="2" | Specifies which receive filter to modify. Range: 0-5&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 +
| width="90%" | ID
 +
|-
 +
| colspan="2" | The ID filter value you wish to use&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:''This call does not return a value''
 
  
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTxIdent'''
 +
|-
 +
| colspan="2" | Set the Tx CAN ID as a generic number. Standard and extended IDs Standard 0-2047 Extended 2048-536870911 &nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | Transmit buffer to load. Range: 0-2&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u32-icon.png]] - ULONG
 +
| width="90%" | ID
 +
|-
 +
| colspan="2" | The ID or Extended ID value you wish to use. Range: 0-536870911&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>SetRxMask</tt></u></span>===
 
Allows the receive ID mask to be configured on the fly allowing different ID ranges to be received.
 
  
'''Parameters'''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckRx'''
 +
|-
 +
| colspan="2" | Checks to see if any messages are available for 'Buffer' specified &nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | Send buffer: 0  to 1&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:[[Variable Types|BYTE]] ''Mask''
 
::Specifies which receive mask to modify. Range: 0-1
 
  
:[[Variable Types|ULONG]] ''ID''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::The ID mask value you wish to use
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRxIDSimple'''
 +
|-
 +
| colspan="2" | Gets the Rx ID as a Integer Standard ID only 0-2047.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | Receive Buffer. Range 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
  
'''Return value'''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetTxID'''
 +
|-
 +
| colspan="2" | Set the Tx CAN ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous,&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | Transmit buffer to load. Range: 0-2&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Hi
 +
|-
 +
| colspan="2" | ID bits 3-10 e.g. ((ID & 0x7F8) >> 3)&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Lo
 +
|-
 +
| colspan="2" | ID bits 0-2 stored in the upper 3 bits of the byte e.g. ((ID & 0x7) << 5)&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
:''This call does not return a value''
 
  
 +
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''ShowLEDs'''
 +
|-
 +
| colspan="2" | Set LED state (External CAN only) &nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | led1
 +
|-
 +
| colspan="2" | Controls LED 1. Range: 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | led2
 +
|-
 +
| colspan="2" | Controls LED 2. Range: 0-1&nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>GetRxData</tt></u></span>===
 
Returns last received message data byte at position Index.
 
  
Buffer parameter is currently ignored
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetRxIdent'''
 +
|-
 +
| colspan="2" | Gets the Rx ID as a Integer Standard and Extended IDs.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u32-icon.png]] - ULONG
 +
| width="90%" style="border-top: 2px solid #000;" | ''Return''
 +
|}
  
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
 
:[[Variable Types|BYTE]] ''Index''
 
 
 
'''Return value'''
 
 
:[[Variable Types|BYTE]]
 
 
 
===<span style="font-weight: normal;"><u><tt>GetRxIDHi</tt></u></span>===
 
Gets the Hi byte Rx ID in register format.
 
 
Standard ID only 0-2047.
 
 
Compatible with v5 component and previous,
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
::Receive Buffer. Range 0-1
 
 
 
'''Return value'''
 
 
:[[Variable Types|BYTE]]
 
 
 
===<span style="font-weight: normal;"><u><tt>SetTxIDSimple</tt></u></span>===
 
Set the Tx CAN ID as a generic number.
 
 
Standard IDs only 0-2047.
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
::Transmit buffer to load. Range: 0-2
 
 
:[[Variable Types|UINT]] ''ID''
 
::The ID value you wish to use. Range: 0-2047
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>SendBuffer</tt></u></span>===
 
Transmits one of the transmit buffers which should have already been populated with an ID and data.
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
::Specifies which transmit buffer to send
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>GetRxDataCount</tt></u></span>===
 
Returns last received message data length.
 
 
Buffer parameter is currently ignored
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
 
 
'''Return value'''
 
 
:[[Variable Types|BYTE]]
 
 
 
===<span style="font-weight: normal;"><u><tt>SetRxFilterID</tt></u></span>===
 
sets the Filter
 
 
Standard mode only
 
 
(for V5 compatibility only)
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Filter''
 
::Specifies which filter to modify. Range: 0-5
 
 
:[[Variable Types|BYTE]] ''Hi''
 
::ID bits 3-10
 
 
:[[Variable Types|BYTE]] ''Lo''
 
::ID bits 0-2 stored in the upper 3 bits of the byte
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>GetRxIDLo</tt></u></span>===
 
Gets the Lo byte Rx ID in register format.
 
 
Standard ID only 0-2047.
 
 
Compatible with v5 component and previous,
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
 
 
'''Return value'''
 
 
:[[Variable Types|BYTE]]
 
 
 
===<span style="font-weight: normal;"><u><tt>SetRxMaskID</tt></u></span>===
 
set the Mask
 
 
Standard ID mode only
 
 
(for V5 compatibility)
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Mask''
 
::Specifies which receive mask to modify. Range: 0-1
 
 
:[[Variable Types|BYTE]] ''Hi''
 
::ID bits 3-10
 
 
:[[Variable Types|BYTE]] ''Lo''
 
::ID bits 0-2 stored in the upper 3 bits of the byte
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>SetRxFilter</tt></u></span>===
 
Allows the receive ID filter to be configured on the fly allowing different ID ranges to be received.
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Filter''
 
::Specifies which receive filter to modify. Range: 0-5
 
 
:[[Variable Types|ULONG]] ''ID''
 
::The ID filter value you wish to use
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>SetTxIdent</tt></u></span>===
 
Set the Tx CAN ID as a generic number.
 
 
Standard and extended IDs
 
 
Standard 0-2047
 
 
Extended 2048-536870911
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
::Transmit buffer to load. Range: 0-2
 
 
:[[Variable Types|ULONG]] ''ID''
 
::The ID or Extended ID value you wish to use. Range: 0-536870911
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>CheckRx</tt></u></span>===
 
Checks to see if any messages are available for 'Buffer' specified
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
::Send buffer: 0  to 1
 
 
 
'''Return value'''
 
 
:[[Variable Types|BYTE]]
 
 
 
===<span style="font-weight: normal;"><u><tt>GetRxIDSimple</tt></u></span>===
 
Gets the Rx ID as a Integer
 
 
Standard ID only 0-2047.
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
::Receive Buffer. Range 0-1
 
 
 
'''Return value'''
 
 
:[[Variable Types|UINT]]
 
 
 
===<span style="font-weight: normal;"><u><tt>SetTxID</tt></u></span>===
 
Set the Tx CAN ID in register format.
 
 
Standard ID only 0-2047.
 
 
Compatible with v5 component and previous,
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
::Transmit buffer to load. Range: 0-2
 
 
:[[Variable Types|BYTE]] ''Hi''
 
::ID bits 3-10 e.g. ((ID & 0x7F8) >> 3)
 
 
:[[Variable Types|BYTE]] ''Lo''
 
::ID bits 0-2 stored in the upper 3 bits of the byte e.g. ((ID & 0x7) << 5)
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>ShowLEDs</tt></u></span>===
 
Set LED state
 
 
(External CAN only)
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''led1''
 
::Controls LED 1. Range: 0-1
 
 
:[[Variable Types|BYTE]] ''led2''
 
::Controls LED 2. Range: 0-1
 
 
 
'''Return value'''
 
 
:''This call does not return a value''
 
 
 
===<span style="font-weight: normal;"><u><tt>GetRxIdent</tt></u></span>===
 
Gets the Rx ID as a Integer
 
 
Standard and Extended IDs.
 
 
'''Parameters'''
 
 
:[[Variable Types|BYTE]] ''Buffer''
 
 
 
'''Return value'''
 
 
:[[Variable Types|ULONG]]
 
 
 
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
 
Must be called before any other CAN component macros to enable and initialise the CAN peripheral.
 
 
'''Parameters'''
 
 
:''This macro has no parameters''
 
  
 
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
'''Return value'''
+
|-
 
+
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
:''This call does not return a value''
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
 
+
|-
 
+
| colspan="2" | Must be called before any other CAN component macros to enable and initialise the CAN peripheral. &nbsp;
 
+
|-
==Simulation macro reference==
+
|-
 
+
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
===<span style="font-weight: normal;"><u><tt>SetBaud</tt></u></span>===
+
| width="90%" style="border-top: 2px solid #000;" | ''Return''
''<span style="color:red;">No additional information</span>''
+
|}
 
 
 
 
 
 
'''Parameters'''
 
 
 
:''This macro has no parameters''
 
 
 
 
 
'''Return value'''
 
 
 
:''This call does not return a value''
 
  
  
Line 567: Line 633:
  
 
==Property reference==
 
==Property reference==
<span style="font-weight: normal;"><u>Channel</u></span>
 
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''CHANNEL_CAN''.
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
Switches between Internal CAN peripheral and External CAN controller IC MCP2515.
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
<span style="font-weight: normal;"><u>Controller Osc</u></span>
+
|-
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''EXT_OSC''.
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Channel
''<span style="color:red;">No additional information</span>''
+
|-
 
+
| colspan="2" | Switches between Internal CAN peripheral and External CAN controller IC MCP2515.&nbsp;
 
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>Bus Rate</u></span>
+
| width="90%" | Controller Osc
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''BUS_RATE''.
+
| colspan="2" | &nbsp;
 
+
|-
Data rate of the bus specified in thousand bits per second, Kbps.
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Bus Rate
<span style="font-weight: normal;"><u>Sync Jump Width</u></span>
+
|-
 
+
| colspan="2" | Data rate of the bus specified in thousand bits per second, Kbps.&nbsp;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''SJW''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
Defines how far a resyncronisation may move the sample point
+
| width="90%" | Sync Jump Width
 
+
|-
<span style="font-weight: normal;"><u>Sample Point</u></span>
+
| colspan="2" | Defines how far a resyncronisation may move the sample point&nbsp;
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''SAMPLE''.
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Sample Point
Point in each bit period where the incoming data is sampled.
+
|-
 
+
| colspan="2" | Point in each bit period where the incoming data is sampled.&nbsp;
<span style="font-weight: normal;"><u>ID Type</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''EXID''.
+
| width="90%" | ID Type
 
+
|-
Switches between using Standard, or Standard and Extended CAN
+
| colspan="2" | Switches between using Standard, or Standard and Extended CAN&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>TX Pin</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | One Shot Mode
This property is of type ''Single digital pin'' and can be referenced with the variable name ''TXPin''.
+
|-
 
+
| colspan="2" | Disabled. Messages will reattempt transmission Enabled. Message will only attempt to transmit once&nbsp;
Internal CAN TX Pin
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>RX Pin</u></span>
+
| width="90%" | CHANNEL
 
+
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''RXPin''.
+
| colspan="2" | SPI Channel selector&nbsp;
 
+
|-
Internal CAN Rx Pin
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | MOSI
<span style="font-weight: normal;"><u>Message ID</u></span>
+
|-
 
+
| colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.&nbsp;
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0ID''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
TX Buffer 0 Message Identifier
+
| width="90%" | MISO
 
+
|-
<span style="font-weight: normal;"><u>Length</u></span>
+
| colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.&nbsp;
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0LEN''.
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | CLK
TX Buffer 0 Number of data bytes
+
|-
 
+
| colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master.&nbsp;
<span style="font-weight: normal;"><u>D0</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0DB0''.
+
| width="90%" | SS
 
+
|-
TX Buffer 0 Data Byte 0
+
| colspan="2" | Chip Select / Slave Select Pin  Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device. &nbsp;
 
+
|-
<span style="font-weight: normal;"><u>D1</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Prescale
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0DB1''.
+
|-
 
+
| colspan="2" | Prescale option selector&nbsp;
TX Buffer 0 Data Byte 1
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>D2</u></span>
+
| width="90%" | Sample Point
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0DB2''.
+
| colspan="2" | Data bit read sample point&nbsp;
 
+
|-
TX Buffer 0 Data Byte 2
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Config Delay
<span style="font-weight: normal;"><u>D3</u></span>
+
|-
 
+
| colspan="2" | &nbsp;
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0DB3''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
TX Buffer 0 Data Byte 3
+
| width="90%" | TX Pin
 
+
|-
<span style="font-weight: normal;"><u>D4</u></span>
+
| colspan="2" | Internal CAN TX Pin&nbsp;
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0DB4''.
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | TX Remap
TX Buffer 0 Data Byte 4
+
|-
 
+
| colspan="2" | Internal CAN Tx Remap Pin&nbsp;
<span style="font-weight: normal;"><u>D5</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0DB5''.
+
| width="90%" | RX Pin
 
+
|-
TX Buffer 0 Data Byte 5
+
| colspan="2" | Internal CAN Rx Pin&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>D6</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | RX Remap
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0DB6''.
+
|-
 
+
| colspan="2" | Internal CAN Rx Remap Pin&nbsp;
TX Buffer 0 Data Byte 6
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
<span style="font-weight: normal;"><u>D7</u></span>
+
| width="90%" | Message ID
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB0DB7''.
+
| colspan="2" | TX Buffer 0 Message Identifier&nbsp;
 
+
|-
TX Buffer 0 Data Byte 7
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | Length
<span style="font-weight: normal;"><u>Message ID</u></span>
+
|-
 
+
| colspan="2" | TX Buffer 0 Number of data bytes&nbsp;
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1ID''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
TX Buffer 1 Message Identifier
+
| width="90%" | D0
 
+
|-
<span style="font-weight: normal;"><u>Length</u></span>
+
| colspan="2" | TX Buffer 0 Data Byte 0&nbsp;
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1LEN''.
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D1
TX Buffer 1 Number of data bytes
+
|-
 
+
| colspan="2" | TX Buffer 0 Data Byte 1&nbsp;
<span style="font-weight: normal;"><u>D0</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1DB0''.
+
| width="90%" | D2
 
+
|-
TX Buffer 1 Data Byte 0
+
| colspan="2" | TX Buffer 0 Data Byte 2&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>D1</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D3
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1DB1''.
+
|-
 
+
| colspan="2" | TX Buffer 0 Data Byte 3&nbsp;
TX Buffer 1 Data Byte 1
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
<span style="font-weight: normal;"><u>D2</u></span>
+
| width="90%" | D4
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1DB2''.
+
| colspan="2" | TX Buffer 0 Data Byte 4&nbsp;
 
+
|-
TX Buffer 1 Data Byte 2
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D5
<span style="font-weight: normal;"><u>D3</u></span>
+
|-
 
+
| colspan="2" | TX Buffer 0 Data Byte 5&nbsp;
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1DB3''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
TX Buffer 1 Data Byte 3
+
| width="90%" | D6
 
+
|-
<span style="font-weight: normal;"><u>D4</u></span>
+
| colspan="2" | TX Buffer 0 Data Byte 6&nbsp;
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1DB4''.
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D7
TX Buffer 1 Data Byte 4
+
|-
 
+
| colspan="2" | TX Buffer 0 Data Byte 7&nbsp;
<span style="font-weight: normal;"><u>D5</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1DB5''.
+
| width="90%" | Message ID
 
+
|-
TX Buffer 1 Data Byte 5
+
| colspan="2" | TX Buffer 1 Message Identifier&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>D6</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | Length
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1DB6''.
+
|-
 
+
| colspan="2" | TX Buffer 1 Number of data bytes&nbsp;
TX Buffer 1 Data Byte 6
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
<span style="font-weight: normal;"><u>D7</u></span>
+
| width="90%" | D0
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB1DB7''.
+
| colspan="2" | TX Buffer 1 Data Byte 0&nbsp;
 
+
|-
TX Buffer 1 Data Byte 7
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D1
<span style="font-weight: normal;"><u>Message ID</u></span>
+
|-
 
+
| colspan="2" | TX Buffer 1 Data Byte 1&nbsp;
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2ID''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
TX Buffer 2 Message Identifier
+
| width="90%" | D2
 
+
|-
<span style="font-weight: normal;"><u>Length</u></span>
+
| colspan="2" | TX Buffer 1 Data Byte 2&nbsp;
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2LEN''.
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D3
TX Buffer 2 Number of data bytes
+
|-
 
+
| colspan="2" | TX Buffer 1 Data Byte 3&nbsp;
<span style="font-weight: normal;"><u>D0</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2DB0''.
+
| width="90%" | D4
 
+
|-
TX Buffer 2 Data Byte 0
+
| colspan="2" | TX Buffer 1 Data Byte 4&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>D1</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D5
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2DB1''.
+
|-
 
+
| colspan="2" | TX Buffer 1 Data Byte 5&nbsp;
TX Buffer 2 Data Byte 1
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
<span style="font-weight: normal;"><u>D2</u></span>
+
| width="90%" | D6
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2DB2''.
+
| colspan="2" | TX Buffer 1 Data Byte 6&nbsp;
 
+
|-
TX Buffer 2 Data Byte 2
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D7
<span style="font-weight: normal;"><u>D3</u></span>
+
|-
 
+
| colspan="2" | TX Buffer 1 Data Byte 7&nbsp;
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2DB3''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
TX Buffer 2 Data Byte 3
+
| width="90%" | Message ID
 
+
|-
<span style="font-weight: normal;"><u>D4</u></span>
+
| colspan="2" | TX Buffer 2 Message Identifier&nbsp;
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2DB4''.
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | Length
TX Buffer 2 Data Byte 4
+
|-
 
+
| colspan="2" | TX Buffer 2 Number of data bytes&nbsp;
<span style="font-weight: normal;"><u>D5</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2DB5''.
+
| width="90%" | D0
 
+
|-
TX Buffer 2 Data Byte 5
+
| colspan="2" | TX Buffer 2 Data Byte 0&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>D6</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D1
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2DB6''.
+
|-
 
+
| colspan="2" | TX Buffer 2 Data Byte 1&nbsp;
TX Buffer 2 Data Byte 6
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
<span style="font-weight: normal;"><u>D7</u></span>
+
| width="90%" | D2
 
+
|-
This property is of type ''Signed integer'' and can be referenced with the variable name ''TXB2DB7''.
+
| colspan="2" | TX Buffer 2 Data Byte 2&nbsp;
 
+
|-
TX Buffer 2 Data Byte 7
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D3
<span style="font-weight: normal;"><u>Settings</u></span>
+
|-
 
+
| colspan="2" | TX Buffer 2 Data Byte 3&nbsp;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''RXB0CFG''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
RX Buffer 0 Message Receive Mode
+
| width="90%" | D4
 
+
|-
<span style="font-weight: normal;"><u>Settings</u></span>
+
| colspan="2" | TX Buffer 2 Data Byte 4&nbsp;
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''RXB1CFG''.
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | D5
RX Buffer 1 Message Receive Mode
+
|-
 
+
| colspan="2" | TX Buffer 2 Data Byte 5&nbsp;
<span style="font-weight: normal;"><u>Label</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
This property is of type ''Line of text'' and can be referenced with the variable name ''label''.
+
| width="90%" | D6
 
+
|-
Comms Flasher Identification Label
+
| colspan="2" | TX Buffer 2 Data Byte 6&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 +
| width="90%" | D7
 +
|-
 +
| colspan="2" | TX Buffer 2 Data Byte 7&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Settings
 +
|-
 +
| colspan="2" | RX Buffer 0 Message Receive Mode&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | Settings
 +
|-
 +
| colspan="2" | RX Buffer 1 Message Receive Mode&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 +
| width="90%" | Scope Traces
 +
|-
 +
| colspan="2" | Selects if the scope traces are automatically generated or not&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 +
| width="90%" | Console Data
 +
|-
 +
| colspan="2" | Selects if the console data is automatically generated or not&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 +
| width="90%" | API
 +
|-
 +
| colspan="2" | &nbsp;
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''
 +
|-
 +
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
 +
| width="90%" | Label
 +
|-
 +
| colspan="2" | Comms Flasher Identification Label&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 +
| width="90%" | Simulate SPI Comms
 +
|-
 +
| colspan="2" | &nbsp;
 +
|}

Revision as of 16:53, 16 November 2021

Author Matrix Ltd
Version 2.9
Category Comms: Interface


CAN (Internal, MCP2515) component

Low level routines for controling the CAN interface either using an external MCP2515 IC and a SPI bus connection or using an internal CAN peripheral if available on your device. Both methods will require a CAN driver IC like the MCP2551 to drive the CAN signals on the bus.

Detailed description

No detailed description exists yet for this component

Examples

Internal CAN schematic

InternalCAN.jpg


External CAN schematic

ExternalCAN.jpg


CAN Message Decoding

The CAN component works together with the injector component to allow you to decode a CAN message ID into a meaningful command.


Example File FC6 Icon.png CAN_Example1 When a key on the keypad is pressed the CAN components transmits a CAN packet.

The CAN packet is decoded by the injector component to give us a meaningful log on the console window.


High Level CAN Data Console

CAN High.jpg


Low Level CAN Data Console

CAN Low.jpg


Reference from CAN Injector to ID decode file, $(srcdir) refers to the current project directory.

CAN File.jpg


Demo CAN ID file File:CANID.csv

CAN DataFile.jpg


CAN Masks and Filters

How to work out which messages will be trapped by a particular mask/filter combination

Note that all values for message id's, masks and filters are numbers between 0x000 and 0x7FF.


Example 1


Mask0 = 0x0FF

Filter0 = 0x100

Filter1 = 0x050


In binary, this looks like:


Mask0 = 000 1111 1111

Filter0 = 001 0000 0000

Filter1 = 000 0101 0000


For the mask, a "1" signifies "check this bit" and a "0" means "ignore this bit"


So, these filters will accept the following messages ("x" = don't care)


Filter0 = xxx 0000 0000

Filter1 = xxx 0101 0000


i.e.


Filter0 = 0x000, 0x100, 0x200, 0x300, 0x400, 0x500, 0x600, 0x700

Filter1 = 0x050, 0x150, 0x250, 0x350, 0x450, 0x550, 0x650, 0x750


Example 2


Mask1 = 0x350

Filter2 = 0x200

Filter3 = 0x123

Filter4 = 0x3FF


Rewriting in binary:


Mask1 = 111 0101 0000

Filter2 = 010 0000 0000

Filter3 = 001 0010 0011

Filter4 = 111 1111 1111


Here, the mask will only check 4 bits and ignore the other 6. Here's what the filters will accept:


Filter2 = 010 x0x0 xxxx

Filter3 = 001 x0x0 xxxx

Filter4 = 111 x1x1 xxxx


They will actually trap a lot of messages (64 each!):


Filter2 = 0x200, 0x201, 0x202, ... 0x220, 0x221, ... 0x280, 0x281, ... 0x2A0, 0x2A1, ... 0x2AF

Filter3 = 0x100, 0x101, 0x102, ... 0x120, 0x121, ... 0x180, 0x181, ... 0x1A0, 0x1A1, ... 0x1AF

Filter4 = 0x750, 0x751, 0x752, ... 0x770, 0x771, ... 0x7D0, 0x7D1, ... 0x7F0, 0x7F1, ... 0x7FF


This second example is not very practical. In general, it is more logical to set the mask so that each filter accepts a consecutive range of messages.


As you can see, the mask determines which bits of the filters are actually looked at. Setting the mask to 0x000 will effectively mean that the filter will accept any incoming message. Also, the value of the mask directly relates to how many messages each filter will trap - i.e. 2^(number of '0' bits in the mask).


A useful way to use the mask would be to ignore the least significant bits. Lets say that you wanted the filters to accept 16 messages each - setting the Mask0 to 0x7F0 would achieve this. Then, setting the filters to the following:


Filter0 = 0x100

Filter1 = 0x110


would mean that the following messages are accepted:


Filter0 = 0x100, 0x101, 0x102, 0x103, 0x104, ... 0x10D, 0x10E, 0x10F

Filter1 = 0x110, 0x111, 0x112, 0x113, 0x114, ... 0x11D, 0x11E, 0x11F


Of course, for simple CAN applications you may wish to only accept one or two messages. Setting the mask to 0x7FF in this instance would mean that only the message ID specified by each filter would be accepted, e.g.


Mask1 = 0x7FF

Filter2 = 0x100

Filter5 = 0x200


This would mean that only messages 0x100 and 0x200 would be accepted into buffer 1.

Downloadable macro reference

Fc9-comp-macro.png ReadSwitches
Returns switch input states from the external MCP2515 device. 0 = No Switch Pressed, 1 = Switch 1 Pressed, 2 = Switch 2 Pressed, 3 = Both Pressed (External CAN only)  
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png SetTxData
Assigns one of the outgoing transmit buffers with data ready to be sent. 
Fc9-u8-icon.png - BYTE Buffer
 
Fc9-u8-icon.png - BYTE Count
 
Fc9-u8-icon.png - BYTE d0
 
Fc9-u8-icon.png - BYTE d1
 
Fc9-u8-icon.png - BYTE d2
 
Fc9-u8-icon.png - BYTE d3
 
Fc9-u8-icon.png - BYTE d4
 
Fc9-u8-icon.png - BYTE d5
 
Fc9-u8-icon.png - BYTE d6
 
Fc9-u8-icon.png - BYTE d7
 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SetRxMask
Allows the receive ID mask to be configured on the fly allowing different ID ranges to be received. 
Fc9-u8-icon.png - BYTE Mask
Specifies which receive mask to modify. Range: 0-1 
Fc9-u32-icon.png - ULONG ID
The ID mask value you wish to use 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png GetRxData
Returns last received message data byte at position Index. Buffer parameter is currently ignored 
Fc9-u8-icon.png - BYTE Buffer
 
Fc9-u8-icon.png - BYTE Index
 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png GetRxIDHi
Gets the Hi byte Rx ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous,  
Fc9-u8-icon.png - BYTE Buffer
Receive Buffer. Range 0-1 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png SetTxIDSimple
Set the Tx CAN ID as a generic number. Standard IDs only 0-2047.  
Fc9-u8-icon.png - BYTE Buffer
Transmit buffer to load. Range: 0-2 
Fc9-u16-icon.png - UINT ID
The ID value you wish to use. Range: 0-2047 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SendBuffer
Transmits one of the transmit buffers which should have already been populated with an ID and data. 
Fc9-u8-icon.png - BYTE Buffer
Specifies which transmit buffer to send 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png GetRxDataCount
Returns last received message data length. Buffer parameter is currently ignored 
Fc9-u8-icon.png - BYTE Buffer
 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png SetRxFilterID
sets the Filter Standard mode only (for V5 compatibility only) 
Fc9-u8-icon.png - BYTE Filter
Specifies which filter to modify. Range: 0-5 
Fc9-u8-icon.png - BYTE Hi
ID bits 3-10 
Fc9-u8-icon.png - BYTE Lo
ID bits 0-2 stored in the upper 3 bits of the byte 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png GetRxIDLo
Gets the Lo byte Rx ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous,  
Fc9-u8-icon.png - BYTE Buffer
 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png SetRxMaskID
set the Mask Standard ID mode only (for V5 compatibility)  
Fc9-u8-icon.png - BYTE Mask
Specifies which receive mask to modify. Range: 0-1 
Fc9-u8-icon.png - BYTE Hi
ID bits 3-10 
Fc9-u8-icon.png - BYTE Lo
ID bits 0-2 stored in the upper 3 bits of the byte 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SetRxFilter
Allows the receive ID filter to be configured on the fly allowing different ID ranges to be received. 
Fc9-u8-icon.png - BYTE Filter
Specifies which receive filter to modify. Range: 0-5 
Fc9-u32-icon.png - ULONG ID
The ID filter value you wish to use 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SetTxIdent
Set the Tx CAN ID as a generic number. Standard and extended IDs Standard 0-2047 Extended 2048-536870911  
Fc9-u8-icon.png - BYTE Buffer
Transmit buffer to load. Range: 0-2 
Fc9-u32-icon.png - ULONG ID
The ID or Extended ID value you wish to use. Range: 0-536870911 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png CheckRx
Checks to see if any messages are available for 'Buffer' specified  
Fc9-u8-icon.png - BYTE Buffer
Send buffer: 0 to 1 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png GetRxIDSimple
Gets the Rx ID as a Integer Standard ID only 0-2047. 
Fc9-u8-icon.png - BYTE Buffer
Receive Buffer. Range 0-1 
Fc9-u16-icon.png - UINT Return


Fc9-comp-macro.png SetTxID
Set the Tx CAN ID in register format. Standard ID only 0-2047. Compatible with v5 component and previous, 
Fc9-u8-icon.png - BYTE Buffer
Transmit buffer to load. Range: 0-2 
Fc9-u8-icon.png - BYTE Hi
ID bits 3-10 e.g. ((ID & 0x7F8) >> 3) 
Fc9-u8-icon.png - BYTE Lo
ID bits 0-2 stored in the upper 3 bits of the byte e.g. ((ID & 0x7) << 5) 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png ShowLEDs
Set LED state (External CAN only)  
Fc9-u8-icon.png - BYTE led1
Controls LED 1. Range: 0-1 
Fc9-u8-icon.png - BYTE led2
Controls LED 2. Range: 0-1 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png GetRxIdent
Gets the Rx ID as a Integer Standard and Extended IDs. 
Fc9-u8-icon.png - BYTE Buffer
 
Fc9-u32-icon.png - ULONG Return


Fc9-comp-macro.png Initialise
Must be called before any other CAN component macros to enable and initialise the CAN peripheral.  
Fc9-void-icon.png - VOID Return



Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Channel
Switches between Internal CAN peripheral and External CAN controller IC MCP2515. 
Fc9-type-16-icon.png Controller Osc
 
Fc9-type-16-icon.png Bus Rate
Data rate of the bus specified in thousand bits per second, Kbps. 
Fc9-type-16-icon.png Sync Jump Width
Defines how far a resyncronisation may move the sample point 
Fc9-type-16-icon.png Sample Point
Point in each bit period where the incoming data is sampled. 
Fc9-type-16-icon.png ID Type
Switches between using Standard, or Standard and Extended CAN 
Fc9-type-16-icon.png One Shot Mode
Disabled. Messages will reattempt transmission Enabled. Message will only attempt to transmit once 
Fc9-type-16-icon.png CHANNEL
SPI Channel selector 
Fc9-type-5-icon.png MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
Fc9-type-5-icon.png MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
Fc9-type-5-icon.png CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
Fc9-type-5-icon.png SS
Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device.  
Fc9-type-16-icon.png Prescale
Prescale option selector 
Fc9-type-16-icon.png Sample Point
Data bit read sample point 
Fc9-type-16-icon.png Config Delay
 
Fc9-type-5-icon.png TX Pin
Internal CAN TX Pin 
Fc9-type-16-icon.png TX Remap
Internal CAN Tx Remap Pin 
Fc9-type-5-icon.png RX Pin
Internal CAN Rx Pin 
Fc9-type-16-icon.png RX Remap
Internal CAN Rx Remap Pin 
Fc9-type-14-icon.png Message ID
TX Buffer 0 Message Identifier 
Fc9-type-14-icon.png Length
TX Buffer 0 Number of data bytes 
Fc9-type-14-icon.png D0
TX Buffer 0 Data Byte 0 
Fc9-type-14-icon.png D1
TX Buffer 0 Data Byte 1 
Fc9-type-14-icon.png D2
TX Buffer 0 Data Byte 2 
Fc9-type-14-icon.png D3
TX Buffer 0 Data Byte 3 
Fc9-type-14-icon.png D4
TX Buffer 0 Data Byte 4 
Fc9-type-14-icon.png D5
TX Buffer 0 Data Byte 5 
Fc9-type-14-icon.png D6
TX Buffer 0 Data Byte 6 
Fc9-type-14-icon.png D7
TX Buffer 0 Data Byte 7 
Fc9-type-14-icon.png Message ID
TX Buffer 1 Message Identifier 
Fc9-type-14-icon.png Length
TX Buffer 1 Number of data bytes 
Fc9-type-14-icon.png D0
TX Buffer 1 Data Byte 0 
Fc9-type-14-icon.png D1
TX Buffer 1 Data Byte 1 
Fc9-type-14-icon.png D2
TX Buffer 1 Data Byte 2 
Fc9-type-14-icon.png D3
TX Buffer 1 Data Byte 3 
Fc9-type-14-icon.png D4
TX Buffer 1 Data Byte 4 
Fc9-type-14-icon.png D5
TX Buffer 1 Data Byte 5 
Fc9-type-14-icon.png D6
TX Buffer 1 Data Byte 6 
Fc9-type-14-icon.png D7
TX Buffer 1 Data Byte 7 
Fc9-type-14-icon.png Message ID
TX Buffer 2 Message Identifier 
Fc9-type-14-icon.png Length
TX Buffer 2 Number of data bytes 
Fc9-type-14-icon.png D0
TX Buffer 2 Data Byte 0 
Fc9-type-14-icon.png D1
TX Buffer 2 Data Byte 1 
Fc9-type-14-icon.png D2
TX Buffer 2 Data Byte 2 
Fc9-type-14-icon.png D3
TX Buffer 2 Data Byte 3 
Fc9-type-14-icon.png D4
TX Buffer 2 Data Byte 4 
Fc9-type-14-icon.png D5
TX Buffer 2 Data Byte 5 
Fc9-type-14-icon.png D6
TX Buffer 2 Data Byte 6 
Fc9-type-14-icon.png D7
TX Buffer 2 Data Byte 7 
Fc9-type-16-icon.png Settings
RX Buffer 0 Message Receive Mode 
Fc9-type-16-icon.png Settings
RX Buffer 1 Message Receive Mode 
Fc9-type-7-icon.png Scope Traces
Selects if the scope traces are automatically generated or not 
Fc9-type-7-icon.png Console Data
Selects if the console data is automatically generated or not 
Fc9-type-16-icon.png API
 
Fc9-conn-icon.png Connections
Fc9-conn-icon.png Simulations
Fc9-type-10-icon.png Label
Comms Flasher Identification Label 
Fc9-type-7-icon.png Simulate SPI Comms