Jump to content

Bot test

From Flowcode Help
Revision as of 13:27, 31 August 2021 by Wiki bot (talk | contribs)
Author Matrix Ltd.
Version 1.4
Category Comms: Interface


I2C Master component

Generic Two Wire I2C Communications Interface

Detailed description

Author Matrix Ltd.
Version 1.4 (Release)
Category Comms: Interface


Image I2C Master component

Generic Two Wire I2C Communications Interface


Examples

More information on I2C can be found here,

Matrix Flowcode Blog: Simplified communications I2C and SPI


Generic I2C EEPROM

Example file demonstrating how to read and write bytes from a generic I2C EEPROM device. I2CEEPROM

Simulated I2C devices

This example uses the I2C master component combined with the DS1307 injector to simulate an I2C communications bus between the target Microcontroller and the virtual DS1307 device. I2C DS1307 Example The panel displays the current time from the DS1307 RAM which is populated to match the system time.


The I2C console shows the communications between the target microcontroller and simulated I2C device.


The DS1307 console shows the contents of RAM memory on the simulated I2C device.


Downloadable macro reference

ReceiveByte
Receives a byte from the I²C bus.  
- BYTE Last
Used to signify the last byte when streaming incoming data. 0=Not last byte, 1=Last Byte 
- BYTE Return


Restart
Outputs a restart condition onto the I²C bus. 
- VOID Return


Stop
Outputs a stop condition onto the I²C bus. 
- VOID Return


Transaction_Write
Attempt to write Length number of bytes to the I2C slave from the given Buffer. Ensure that the Buffer is large enough. Returns the number of bytes written, the caller should check that this matches requested Length 
- BYTE Buffer
Buffer of bytes to write to the I2C 
- UINT Length
Number of bytes to send out, MS bit 0x8000 signifies no Stop if set 
- UINT Return


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. 
- BYTE Data
Data byte to send on the I²C bus. 
- BYTE Return


GenericWriteRegister
Function to perform a generic I2C Write transaction. The 7-bit device ID is automatically shifted up by one bit to make room for the read/write bit. 
- BYTE Device_ID
7-bit Device Address ID 
- UINT Address
 
- BYTE Data
Data Byte 
- BYTE AddressByteCount
Specifies the number of address bytes, Range: 1 or 2 
- VOID Return


Transaction_Uninit
Uninitialise the I2C interface 
- VOID Return


GenericReadRegister
Function to perform a generic I2C read. The 7-bit device ID is automatically shifted up by one bit to make room for the read/write bit. Returns the data from the location specified. 
- BYTE Device_ID
7-bit Device Address ID 
- UINT Address
 
- BYTE AddressByteCount
Specifies the number of address bytes, Range: 1 or 2 
- BYTE Return


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 
- BYTE Buffer
Buffer to store the incoming byte data 
- UINT Length
Number of bytes to read 
- UINT Return


Start
Outputs a start condition onto the I²C bus. 
- VOID Return


Transaction_Initialise
Initialise the I2C interface to communicate with a Slave device at Address Returns 0 on fail, 1 on success 
- BYTE Address
7-bit I2C Address without the shift for the R/W bit 
- BYTE Return


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. 
- VOID Return



Property reference

Properties
Channel
Channel selection 
Baud Select
Baud rate option selector 
Baud Rate
Baud rate to be used 
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.  
Slew Rate Control
Slew Rate Control Enabled or Disabled 
SMBus Inputs
When Enabled input logic thresholds are compliant with SMBus specification 
Connections
SDA
Pin used for SDA (data signal) 
SCL
Pin used for SCL (clock signal) 
Simulations
Label
Label shown on the comms flasher on the simulation panel. 
Scope Traces
Selects if the scope traces are automatically generated or not 
Console Data
Selects if the console data is automatically generated or not 
API