As an example of the
operation if the I2C function of the CGMMSTICK1, this example
interfaces to a PCF8574A I/O expansion device.
I/O Pins 12 and 13 are
used for I2C, as described in the documentation.
The code used in this
example assumes that the address pins (A0-A2) are all grounded,
giving this chip an address (offset) of 0.
The example code runs a
'cylon' pattern on the LEDs.
' Enable I2C
' speed = 100 kHz
' timeout = 100 milliseconds
I2CEN 100, 100
DO
FOR loop1 = 0 TO 7
cylon = 2^loop1
cylon = (cylon XOR &hFF)
' Send I2C command to
PCF8574A
' 8574A address = &h38
' send 1 byte
I2CSEND &h38, 0, 1,
cylon
PAUSE 100
NEXT loop1
FOR loop2 = 6 TO 1 STEP -1
cylon = 2^loop2
cylon = (cylon XOR &hFF)
' Send I2C command to
PCF8574A
' 8574A address = &h38
' send 1 byte
I2CSEND &h38, 0, 1,
cylon
PAUSE 100
NEXT loop2
LOOP
' Disable I2C
I2CDIS
Purchase a CGMMSTICK1 Download of Maximite Integrated Development Environment: MMIDE
No comments:
Post a Comment