ELECTRONICS - [I²C board] - [page 3/5]
The software was written to work on a 8051 microprocessor. It was written in Assembler because we weren't allowed to use any high programming languages for this project.
I wrote two functions: an I2C read and a I2C write function.
I won't write too much about these functions because its unlikely you will use this board on a 8051 microprocessor. The board can be used on PIC microcontrollers as well: you only need to rewrite the software.
This function will request the output states from a specific I2C device. It requires a single parameter: the I2C address of the device to read. This address must be placed in the register R0 before the subroutine is called.
After calling the function the retrieved data will be available in the ACCU (Accumulator) register.
The write function will write a certain value to a specific I2C device. The function needs 2 parameters: the address of the I2C device and the 8-bit data.
You have to set the data in 2 registers before you can call the I2C write function: The address must be stored in register R0 (IADDR), the data must be stored in register R1 (IBYTE).
Copyright ©1998-2022 Vanderhaegen Bart - last modified: August 24, 2013