Difference between revisions of "Component: I2C Multiplexer (TCA9548A) (Comms: System)"

From Flowcode Help
Jump to navigationJump to search
Line 1: Line 1:
 
+
{| style="width:50%"
 
 
{| width="50%"
 
 
|-
 
|-
| width="20%" style="color: gray;" | Author
+
| width="20%" style="color:gray;" | Author
 
| MatrixTSL
 
| MatrixTSL
 
|-
 
|-
| width="20%" style="color: gray;" | Version
+
| width="20%" style="color:gray;" | Version
| 1.0 (Release)
+
| 1.0
 
|-
 
|-
| width="20%" style="color: gray;" | Category
+
| width="20%" style="color:gray;" | Category
 
| Comms: System
 
| Comms: System
 
|}
 
|}
  
  
 +
==I2C Multiplexer (TCA9548A) component==
 +
An I2C multiplexing IC allowing up to 8 different I2C busses to be connected to a single I2C channel on your target microcontroller.
  
==[[File:Component Icon 5915b437_6925_4d90_a0f8_f91702837bdb.png|Image]] I2C Multiplexer (TCA9548A) component==
+
==Detailed description==
An I2C multiplexing IC allowing up to 8 different I2C busses to be connected to a single
+
 
I2C channel on your target microcontroller.
+
''No detailed description exists yet for this component''
  
 
==Examples==
 
==Examples==
 +
 +
  
 
Here we have a simple example showing how to use the multiplexer to connect multiple of the same I2C sensor IC to the microcontroller.
 
Here we have a simple example showing how to use the multiplexer to connect multiple of the same I2C sensor IC to the microcontroller.
Line 30: Line 32:
 
==Downloadable macro reference==
 
==Downloadable macro reference==
  
===<span style="font-weight: normal;"><u><tt>SelectChannel</tt></u></span>===
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
Selects a single output channel to multiplex the I2C output to (0-7).
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SelectChannel'''
 +
|-
 +
| colspan="2" | Selects a single output channel to multiplex the I2C output to (0-7).&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Channel
 +
|-
 +
| colspan="2" | Range: 0-7&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'''
 
  
:[[Variable Types|BYTE]] ''Channel''
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
::Range: 0-7
+
|-
 +
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
 +
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetChannelMask'''
 +
|-
 +
| colspan="2" | Allows a user determined number of channels to be connected to the I2C bus.&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Mask
 +
|-
 +
| colspan="2" | Range: 0-255 / Bit0=CH0 EN / Bit1 = CH1 EN etc&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;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Startup the I2C bus ready for communications.&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;" | '''Transaction_Read'''
 +
|-
 +
| colspan="2" | Attempt to read Length number of bytes from the I2C slave to the given Buffer. Ensure that the Buffer is large enough.  Returns number of bytes read, caller should check that this matches requested Length&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Buffer
 +
|-
 +
| colspan="2" | Buffer to store the incoming byte data&nbsp;
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT
 +
| width="90%" | Length
 +
|-
 +
| colspan="2" | Number of bytes to read&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''
 +
|}
  
===<span style="font-weight: normal;"><u><tt>SetChannelMask</tt></u></span>===
 
Allows a user determined number of channels to be connected to the I2C bus.
 
  
'''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;" | '''Start'''
 +
|-
 +
| colspan="2" | Outputs a start condition onto the I²C bus.&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]] ''Mask''
 
::Range: 0-255 / Bit0=CH0 EN / Bit1 = CH1 EN etc
 
  
 +
{| 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;" | '''Transaction_Initialise'''
 +
|-
 +
| colspan="2" | Initialise the I2C interface to communicate with a Slave device at Address Returns 0 on fail, 1 on success&nbsp;
 +
|-
 +
|-
 +
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
 +
| width="90%" | Address
 +
|-
 +
| colspan="2" | 7-bit I2C Address without the shift for the R/W bit&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''
 +
|}
  
'''Return value'''
 
  
:''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]]
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
Startup the I2C bus ready for communications.
+
|-
 
+
| 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;
'''Parameters'''
+
|-
 
+
|-
:''This macro has no parameters''
+
| 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'''
 
 
 
:''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;" | '''Initialise'''
 +
|-
 +
| colspan="2" | Initialise the sensor configuration as set by the component properties. Sets the default intigration time and gain as well as enable the sensor.&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>Address Bits</u></span>
 
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''AddressBits''.
+
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
 
+
|-
''<span style="color:red;">No additional information</span>''
+
| 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>Channel</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Address Bits
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c1::CHANNEL''.
+
|-
 
+
| colspan="2" | &nbsp;
Channel selection
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
<span style="font-weight: normal;"><u>SDA</u></span>
+
| width="90%" | Stop Delay
 
+
|-
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c1::SDA''.
+
| 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;
 
+
|-
Pin used for SDA (data signal)
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Baud Select
<span style="font-weight: normal;"><u>SCL</u></span>
+
|-
 
+
| colspan="2" | Baud rate option selector&nbsp;
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_i2c1::SCL''.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-14-icon.png]]
Pin used for SCL (clock signal)
+
| width="90%" | Baud Rate
 
+
|-
<span style="font-weight: normal;"><u>Stop Delay</u></span>
+
| colspan="2" | Baud rate to be used&nbsp;
 
+
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c1::StopDel''.
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Scope Traces
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not  
+
|-
 
+
| colspan="2" | Selects if the component pin connections are automatically generated on the data recorder window or not. Yes: Automatically add the component pins to a group on the data recorder which will reflect the sim data during simultion. No: Do not show the pin signals on the data recorder window.&nbsp;
a 10ms delay between an I2C stop event and the next I2C start event.
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Console Data
 
+
|-
Most modern microcontrollers will not have a problem so this property can be disabled to speed up the  
+
| colspan="2" | Selects if the console data is automatically generated or not&nbsp;
 
+
|-
I2C communications.
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
 
+
| width="90%" | Injector
<span style="font-weight: normal;"><u>Baud Select</u></span>
+
|-
 
+
| colspan="2" | Specifies the injector component on the panel to interact with to provide comms simulation.&nbsp;
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c1::BAUD_LIST''.
+
|-
 
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
Baud rate option selector
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Connections'''  
 
+
|-
<span style="font-weight: normal;"><u>Baud Rate</u></span>
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_i2c1::BAUD''.
+
| width="90%" | Channel
 
+
|-
Baud rate to be used
+
| colspan="2" | Channel selection&nbsp;
 
+
|-
<span style="font-weight: normal;"><u>Simulate Comms</u></span>
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | SDA
This property is of type ''True or false'' and can be referenced with the variable name ''SimComms''.
+
|-
 
+
| colspan="2" | Pin used for SDA (data signal)&nbsp;
''<span style="color:red;">No additional information</span>''
+
|-
 
+
| width="10%" align="center" | [[File:Fc9-type-5-icon.png]]
 
+
| width="90%" | SCL
 
+
|-
<span style="font-weight: normal;"><u>Scope Traces</u></span>
+
| colspan="2" | Pin used for SCL (clock signal)&nbsp;
 
+
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c1::ScopeTraces''.
+
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-conn-icon.png]]
 
+
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Simulations'''  
Selects if the component pin connections are automatically generated on the data recorder window or not.
+
|-
 
+
|-
Yes: Automatically add the component pins to a group on the data recorder which will reflect the sim data during simultion.
+
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
 
+
| width="90%" | Simulate Comms
No: Do not show the pin signals on the data recorder window.
+
|-
 
+
| colspan="2" | &nbsp;
<span style="font-weight: normal;"><u>Console Data</u></span>
+
|}
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_i2c1::ConsoleData''.
 
 
 
Selects if the console data is automatically generated or not
 
 
 
<span style="font-weight: normal;"><u>Injector</u></span>
 
 
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_i2c1::Injector''.
 
 
 
Specifies the injector component on the panel to interact with to provide comms simulation.
 

Revision as of 19:47, 16 November 2021

Author MatrixTSL
Version 1.0
Category Comms: System


I2C Multiplexer (TCA9548A) component

An I2C multiplexing IC allowing up to 8 different I2C busses to be connected to a single I2C channel on your target microcontroller.

Detailed description

No detailed description exists yet for this component

Examples

Here we have a simple example showing how to use the multiplexer to connect multiple of the same I2C sensor IC to the microcontroller.

The multiplexer IC is connected directly to the microcontroller I2C pins and up to 8 temp/humidity sensors are connected to the CH0-CH7 I2C pins of the multiplexer.


FC6 Icon.png I2C Multiplex Example

Downloadable macro reference

Fc9-comp-macro.png SelectChannel
Selects a single output channel to multiplex the I2C output to (0-7). 
Fc9-u8-icon.png - BYTE Channel
Range: 0-7 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png SetChannelMask
Allows a user determined number of channels to be connected to the I2C bus. 
Fc9-u8-icon.png - BYTE Mask
Range: 0-255 / Bit0=CH0 EN / Bit1 = CH1 EN etc 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Initialise
Startup the I2C bus ready for communications. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Transaction_Read
Attempt to read Length number of bytes from the I2C slave to the given Buffer. Ensure that the Buffer is large enough. Returns number of bytes read, caller should check that this matches requested Length 
Fc9-u8-icon.png - BYTE Buffer
Buffer to store the incoming byte data 
Fc9-u16-icon.png - UINT Length
Number of bytes to read 
Fc9-u16-icon.png - UINT Return


Fc9-comp-macro.png Start
Outputs a start condition onto the I²C bus. 
Fc9-void-icon.png - VOID Return


Fc9-comp-macro.png Transaction_Initialise
Initialise the I2C interface to communicate with a Slave device at Address Returns 0 on fail, 1 on success 
Fc9-u8-icon.png - BYTE Address
7-bit I2C Address without the shift for the R/W bit 
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


Fc9-comp-macro.png Initialise
Initialise the sensor configuration as set by the component properties. Sets the default intigration time and gain as well as enable the sensor. 
Fc9-void-icon.png - VOID Return



Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Address Bits
 
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-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 Scope Traces
Selects if the component pin connections are automatically generated on the data recorder window or not. Yes: Automatically add the component pins to a group on the data recorder which will reflect the sim data during simultion. No: Do not show the pin signals on the data recorder window. 
Fc9-type-7-icon.png Console Data
Selects if the console data is automatically generated or not 
Fc9-type-16-icon.png Injector
Specifies the injector component on the panel to interact with to provide comms simulation. 
Fc9-conn-icon.png Connections
Fc9-type-16-icon.png Channel
Channel selection 
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 Simulations
Fc9-type-7-icon.png Simulate Comms