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

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
(5 intermediate revisions by the same user 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.3 (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.
 
  
Returns the data received, and sends either Ack or Nak
 
  
Set parameter Last as: 1=Last=Nak, 0=Ack=More
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''Last''
 
::Used to signify the last byte when streaming incoming data. 0=Not last byte, 1=Last Byte
 
  
 +
''No detailed description exists yet for this component''
  
'''Return value'''
+
==Examples==
  
:[[Variable Types|BYTE]]
 
  
  
===<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>Check_Status</tt></u></span>===
 
Returns the Slave Status.
 
  
Bit 0 = 1 Indicates address/data byte available in the buffer to read
+
===PIC16F1937 Examples===
  
Bit 5 = 1 Indicates that the last byte received or transmitted was data (else address)
+
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}}
  
'''Parameters'''
+
{{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 macro has no parameters''
+
{{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===
  
'''Return value'''
+
Example program showing how to use the I2C Slave on an ECIO40P device.
 +
{{Fcfile|ECIO40P_I2C_Master.fcfx|Master Example}}
  
:[[Variable Types|BYTE]]
+
{{Fcfile|ECIO40P_I2C_Slave.fcfx|Slave Example}}
  
 +
==Downloadable macro reference==
  
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Enables the I²C hardware and performs some initialization.
+
|-
 +
| 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''
 +
|}
  
Should be called at the start of the program or at least before any of the other I²C functions are called.
 
  
'''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;" | '''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''
 +
|}
  
:''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;" | '''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''
 +
|}
  
  
 +
{| 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''
 +
|}
  
==Simulation macro reference==
 
  
''This component does not contain any simulation macros''
 
  
  
 
==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 ''cal_i2c::CHANNEL''.
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
Channel selection
+
| 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>Baud Select</u></span>
+
|-
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::BAUD_LIST''.
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Bus Settings
Baud rate option selector
+
|-
 
+
|-
<span style="font-weight: normal;"><u>Baud Rate</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Channel
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_i2c::BAUD''.
+
|-
 
+
| colspan="2" | Channel selection&nbsp;
Baud rate to be used
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>Stop Delay</u></span>
+
| width="90%" | Baud Select
 
+
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::StopDel''.
+
| colspan="2" | Baud rate option selector&nbsp;
 
+
|-
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not  
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
 
+
| width="90%" | Baud Rate
a 10ms delay between an I2C stop event and the next I2C start event.
+
|-
 
+
| colspan="2" | Baud rate to be used&nbsp;
 
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
Most modern microcontrollers will not have a problem so this property can be disabled to speed up the  
+
| width="90%" | Stop Delay
 
+
|-
I2C communications.
+
| 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;
 
+
|-
<span style="font-weight: normal;"><u>Slave Address</u></span>
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Slave Setttings
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''Slave_Address''.
+
|-
 
+
|-
''<span style="color:red;">No additional information</span>''
+
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
 
+
| width="90%" | Slave Address
 
+
|-
 
+
| colspan="2" | &nbsp;
<span style="font-weight: normal;"><u>Mask</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-21-icon.png]]
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''Mask''.
+
| width="90%" | Mask
 
+
|-
0 - don't care;
+
| 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;
 
+
|-
1 - perform match;
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections
So address of 0x30 and mask of 0xF0 will allow the slave to respond to addresses of 0x30, 0x31, 0x32, …, 0x3F
+
|-
 
+
|-
<span style="font-weight: normal;"><u>SDA</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | SDA
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c::SDA''.
+
|-
 
+
| colspan="2" | Pin used for SDA (data signal)&nbsp;
Pin used for SDA (data signal)
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
<span style="font-weight: normal;"><u>SCL</u></span>
+
| width="90%" | SCL
 
+
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c::SCL''.
+
| colspan="2" | Pin used for SCL (clock signal)&nbsp;
 
+
|-
Pin used for SCL (clock signal)
+
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
<span style="font-weight: normal;"><u>Label</u></span>
+
|-
 
+
|-
This property is of type ''Line of text'' and can be referenced with the variable name ''label''.
+
| width="10%" align="center" | [[File:Fc9-type-10-icon.png]]
 
+
| width="90%" | Label
Label shown on the comms flasher on the simulation panel.
+
|-
 
+
| colspan="2" | Label shown on the comms flasher on the simulation panel.&nbsp;
<span style="font-weight: normal;"><u>Scope Traces</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::ScopeTraces''.
+
| width="90%" | Scope Traces
 
+
|-
Selects if the scope traces are automatically generated or not
+
| colspan="2" | Selects if the scope traces are automatically generated or not&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Console Data</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Console Data
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c::ConsoleData''.
+
|-
 
+
| colspan="2" | Selects if the console data is automatically generated or not&nbsp;
Selects if the console data is automatically generated or not
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
<span style="font-weight: normal;"><u>Injector</u></span>
+
| width="90%" | API
 
+
|-
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c::Injector''.
+
| colspan="2" | &nbsp;
 
+
|}
''<span style="color:red;">No additional information</span>''
 

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