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

From Flowcode Help
Jump to navigationJump to search
 
Line 59: Line 59:
  
  
 
+
''<span style="color:red;">No additional examples</span>''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
===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}}
 
 
 
{{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}}
 
 
 
{{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}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
==Macro reference==
 
==Macro reference==

Latest revision as of 10:16, 16 January 2024

Author Matrix Ltd.
Version 1.3
Category Comms: Interface


I2C Slave component

Generic Two Wire I2C Communications Interface

Component Source Code

Please click here to download the component source project: FC_Comp_Source_I2C_Slave.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_I2C_Slave.fcfx

Detailed description

No detailed description exists yet for this component

Examples

No additional examples

Macro reference

Check_Status

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


Initialise

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


ReceiveByte

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


TransmitByte

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


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