Difference between revisions of "Component: I2C Slave (Comms: Interface)"

From Flowcode Help
Jump to navigationJump to search
(XML import BR)
 
(6 intermediate revisions by 2 users not shown)
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
| 1.2 (Release)
+
| 1.3
 
|-
 
|-
| width="20%" style="color: gray;" | Category
+
| width="20%" style="color:gray;" | Category
 
| Comms: Interface
 
| Comms: Interface
 
|}
 
|}
  
  
 
+
==I2C Slave component==
==[[File:Component Icon eac43fda_0bc5_4b08_881c_6d3e364f2eff.png|Image]] I2C Slave component==
 
 
Generic Two Wire I2C Communications Interface
 
Generic Two Wire I2C Communications Interface
  
==Examples==
+
==Component Pack==
===PIC16F1937 Examples===
 
  
The slave device is connected to a bank of switches, the master device to a bank of LEDs. The value of the switches is passed to the master LEDs.
+
COMMSC
{{Fcfile|1. I2C Master Read.fcfx|Master Read Example}}
 
  
{{Fcfile|1. I2C Slave switches.fcfx|Slave Switches Example}}
+
==Detailed description==
The slave device is connected to a bank of LEDs, the master device to a bank of switches. The value of the switches is passed to the slave LEDs.
 
{{Fcfile|2. I2C Master Switches.fcfx|Master Send Example}}
 
  
{{Fcfile|2. I2C Slave LEDs.fcfx|Slave LEDs Example}}
 
===Arduino Uno Examples===
 
  
Example program showing how to use the I2C Slave on an AVR Arduino device.
 
{{Fcfile|I2C Uno slave.fcfx|I2C Slave Arduino Uno Example}}
 
===ECIO40P Examples===
 
  
Example program showing how to use the I2C Slave on an ECIO40P device.
 
{{Fcfile|ECIO40P_I2C_Master.fcfx|Master Example}}
 
  
{{Fcfile|ECIO40P_I2C_Slave.fcfx|Slave Example}}
 
  
==Downloadable macro reference==
 
  
===<span style="font-weight: normal;"><u><tt>ReceiveByte</tt></u></span>===
 
Receives a byte from the I²C bus.
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Last''
 
::Used to signify the last byte when streaming incoming data. 0=Not last byte, 1=Last Byte
 
  
  
'''Return value'''
 
  
:[[Variable Types|BYTE]]
+
''No detailed description exists yet for this component''
  
 +
==Examples==
  
===<span style="font-weight: normal;"><u><tt>TransmitByte</tt></u></span>===
 
Sends a byte on the I²C bus. Returns the acknowledge if any.
 
  
0 represents that data was acknowledged and 1 represents no acknowledge was detected.
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Data''
 
::Data byte to send on the I²C bus.
 
  
  
'''Return value'''
 
  
:[[Variable Types|BYTE]]
 
  
  
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
 
Enables the I²C hardware and performs some initialization.
 
  
Should be called at the start of the program or at least before any of the other I²C functions are called.
 
  
'''Parameters'''
 
  
:''This macro has no parameters''
+
===PIC16F1937 Examples===
  
 +
The slave device is connected to a bank of switches, the master device to a bank of LEDs. The value of the switches is passed to the master LEDs.
 +
{{Fcfile|1. I2C Master Read.fcfx|Master Read Example}}
  
'''Return value'''
+
{{Fcfile|1. I2C Slave switches.fcfx|Slave Switches Example}}
 +
The slave device is connected to a bank of LEDs, the master device to a bank of switches. The value of the switches is passed to the slave LEDs.
 +
{{Fcfile|2. I2C Master Switches.fcfx|Master Send Example}}
  
:''This call does not return a value''
+
{{Fcfile|2. I2C Slave LEDs.fcfx|Slave LEDs Example}}
 +
===Arduino Uno Examples===
  
 +
Example program showing how to use the I2C Slave on an AVR Arduino device.
 +
{{Fcfile|I2C Uno slave.fcfx|I2C Slave Arduino Uno Example}}
 +
===ECIO40P Examples===
  
 +
Example program showing how to use the I2C Slave on an ECIO40P device.
 +
{{Fcfile|ECIO40P_I2C_Master.fcfx|Master Example}}
  
==Simulation macro reference==
+
{{Fcfile|ECIO40P_I2C_Slave.fcfx|Slave Example}}
  
''This component does not contain any simulation macros''
+
==Downloadable macro reference==
  
 +
{| 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;" | '''ReceiveByte'''
 +
|-
 +
| colspan="2" | Receives a byte from the I²C bus. Returns the data received, and sends either Ack or Nak Set parameter Last as: 1=Last=Nak, 0=Ack=More&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Last
 +
|-
 +
| colspan="2" | Used to signify the last byte when streaming incoming data. 0=Not last byte, 1=Last Byte&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''
 +
|}
  
==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''.
+
{| 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;" | '''TransmitByte'''
 +
|-
 +
| colspan="2" | Sends a byte on the I²C bus. Returns the acknowledge if any.  0 represents that data was acknowledged and 1 represents no acknowledge was detected.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Data
 +
|-
 +
| colspan="2" | Data byte to send on the I²C bus.&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''
 +
|}
  
Specifies the I2C peripheral used by the component.
 
  
Hardware channels are defined by the number of I2C peripherals available onboard your target microcontroller.
+
{| 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;" | '''Check_Status'''
 +
|-
 +
| colspan="2" | Returns the Slave Status. Bit 0 = 1 Indicates address/data byte available in the buffer to read Bit 5 = 1 Indicates that the last byte received or transmitted was data (else address)&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''
 +
|}
  
Software channels use standard I/O pins allowing you to connect the I2C bus to pretty much any pin.
 
  
<span style="font-weight: normal;"><u>Baud Select</u></span>
+
{| 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;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Enables the I²C hardware and performs some initialization. Should be called at the start of the program or at least before any of the other I²C functions are called.&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 property is of type ''Fixed list of ints'' and can be referenced with the variable name ''BAUD_LIST''.
 
  
Sets the rate of the I2C clock which sets the maximum number of bits per second that can be sent or received.
 
  
<span style="font-weight: normal;"><u>Slew Rate Control</u></span>
 
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''SRC''.
+
==Property reference==
  
The slew rate control only works with hardware I2C channels but acts to modify the overall baud to ensure
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
that signals are being transferred correctly based on how fast the control signals are able to rise and fall.
+
| 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>SMBus Inputs</u></span>
+
|-
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''SMB''.
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Bus Settings
The SMBus Inputs only works with hardware I2C channels but acts to modify the I2C driver to be compatible with SM Bus.
+
|-
 
+
|-
<span style="font-weight: normal;"><u>Data (SDA)</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Channel
This property is of type ''Single digital pin'' and can be referenced with the variable name ''SDA''.
+
|-
 
+
| colspan="2" | Channel selection&nbsp;
I2C data pin commonly referred to as SDA which represents serial data
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>Clock (SCL)</u></span>
+
| width="90%" | Baud Select
 
+
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''SCL''.
+
| colspan="2" | Baud rate option selector&nbsp;
 
+
|-
I2C clock pin commonly referred to as SCL which represents serial clock
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | Baud Rate
<span style="font-weight: normal;"><u>Label</u></span>
+
|-
 
+
| colspan="2" | Baud rate to be used&nbsp;
This property is of type ''Line of text'' and can be referenced with the variable name ''label''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
Label shown on the comms flasher on the simulation panel.
+
| width="90%" | Stop Delay
 
+
|-
<span style="font-weight: normal;"><u>Injector</u></span>
+
| colspan="2" | On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not  a 10ms delay between an I2C stop event and the next I2C start event.  Most modern microcontrollers will not have a problem so this property can be disabled to speed up the  I2C communications. &nbsp;
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''Injector''.
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Slave Setttings
Lists all the available injector components on the panel to allow the I2C data to have meaning.
+
|-
 
+
|-
Injectors are available to let you directly type in values, simulate devices and communicate between multiple instances of Flowcode.
+
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
 
+
| width="90%" | Slave Address
<span style="font-weight: normal;"><u>Slave Address</u></span>
+
|-
 
+
| colspan="2" | &nbsp;
This property is of type ''Signed integer'' and can be referenced with the variable name ''Slave_Address''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
''<span style="color:red;">No additional information</span>''
+
| width="90%" | Mask
 
+
|-
 
+
| colspan="2" | 0 - don't care; 1 - perform match; So address of 0x30 and mask of 0xF0 will allow the slave to respond to addresses of 0x30, 0x31, 0x32, …, 0x3F&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Mask</u></span>
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
This property is of type ''Signed integer'' and can be referenced with the variable name ''Mask''.
+
|-
 
+
|-
0 - don't care;
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | SDA
1 - perform match;
+
|-
 
+
| colspan="2" | Pin used for SDA (data signal)&nbsp;
So address of 0x30 and mask of 0xF0 will allow the slave to respond to addresses of 0x30, 0x31, 0x32, …, 0x3F
+
|-
 +
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 +
| width="90%" | SCL
 +
|-
 +
| colspan="2" | Pin used for SCL (clock signal)&nbsp;
 +
|-
 +
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 +
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
 +
| width="90%" | Label
 +
|-
 +
| colspan="2" | Label shown on the comms flasher on the simulation panel.&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;
 +
|}

Latest revision as of 17:20, 9 November 2022

Author Matrix Ltd.
Version 1.3
Category Comms: Interface


I2C Slave component

Generic Two Wire I2C Communications Interface

Component Pack

COMMSC

Detailed description

No detailed description exists yet for this component

Examples

PIC16F1937 Examples

The slave device is connected to a bank of switches, the master device to a bank of LEDs. The value of the switches is passed to the master LEDs. FC6 Icon.png Master Read Example

FC6 Icon.png Slave Switches Example The slave device is connected to a bank of LEDs, the master device to a bank of switches. The value of the switches is passed to the slave LEDs. FC6 Icon.png Master Send Example

FC6 Icon.png Slave LEDs Example

Arduino Uno Examples

Example program showing how to use the I2C Slave on an AVR Arduino device. FC6 Icon.png I2C Slave Arduino Uno Example

ECIO40P Examples

Example program showing how to use the I2C Slave on an ECIO40P device. FC6 Icon.png Master Example

FC6 Icon.png Slave Example

Downloadable macro reference

Fc9-comp-macro.png ReceiveByte
Receives a byte from the I²C bus. Returns the data received, and sends either Ack or Nak Set parameter Last as: 1=Last=Nak, 0=Ack=More 
Fc9-u8-icon.png - BYTE Last
Used to signify the last byte when streaming incoming data. 0=Not last byte, 1=Last Byte 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png TransmitByte
Sends a byte on the I²C bus. Returns the acknowledge if any. 0 represents that data was acknowledged and 1 represents no acknowledge was detected. 
Fc9-u8-icon.png - BYTE Data
Data byte to send on the I²C bus. 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png Check_Status
Returns the Slave Status. Bit 0 = 1 Indicates address/data byte available in the buffer to read Bit 5 = 1 Indicates that the last byte received or transmitted was data (else address) 
Fc9-u8-icon.png - BYTE Return


Fc9-comp-macro.png Initialise
Enables the I²C hardware and performs some initialization. Should be called at the start of the program or at least before any of the other I²C functions are called. 
Fc9-void-icon.png - VOID Return



Property reference

Fc9-prop-icon.png Properties
Fc9-conn-icon.png Bus Settings
Fc9-type-16-icon.png Channel
Channel selection 
Fc9-type-16-icon.png Baud Select
Baud rate option selector 
Fc9-type-14-icon.png Baud Rate
Baud rate to be used 
Fc9-type-7-icon.png Stop Delay
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not a 10ms delay between an I2C stop event and the next I2C start event. Most modern microcontrollers will not have a problem so this property can be disabled to speed up the I2C communications.  
Fc9-conn-icon.png Slave Setttings
Fc9-type-21-icon.png Slave Address
 
Fc9-type-21-icon.png Mask
0 - don't care; 1 - perform match; So address of 0x30 and mask of 0xF0 will allow the slave to respond to addresses of 0x30, 0x31, 0x32, …, 0x3F 
Fc9-conn-icon.png Connections
Fc9-type-5-icon.png SDA
Pin used for SDA (data signal) 
Fc9-type-5-icon.png SCL
Pin used for SCL (clock signal) 
Fc9-conn-icon.png Simulation
Fc9-type-10-icon.png Label
Label shown on the comms flasher on the simulation panel. 
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