User Manual

MCP Series
Brushed DC Motor Controllers
MCP Series User Manual
168
I2COUT..I2COUTNS
Syntax
i2cout {label,timeout}, [databyte1, ..., databyteN]
i2coutns {label,timeout}, [databyte1, ..., databyteN]
Label - is a label to jump to if the timeout triggers.
Timeout - is the time in milliseconds to wait for a byte to transfer.
DataBytes - is a list of byte sized variables or expressions that are the
values to be sent to an attached I2C device. The only limit to the number of data
bytes in one command is determined by the device itself.
Description
The I2COUT command combined with the I2COUTNS and I2CIN command can communicate
with any I2C compatible devices. The specic data to send and receive from any particular I2C
device will depend on the device. In general you will send an address/control byte that lets the
I2C device know you are trying to talk to it, since multiple devices can be on one bus, and in
what direction you will be talking to it, sending or receiving. The difference between I2COUT and
I2COUTNS is that I2COUTNS does not send a stop signal when it nishes. This allows the user to
send a repeated start by executing another I2COUT/I2COUTNS orI2CIN command.
;example to read a value from an MPU-6050
temp var long
main
pause 10
;send WHOAMI command
i2cout error,10,[0xd0,0x75]
;read reply
i2coutns error,10,[0xd1]
i2cin error,10,[temp]
puts 0,[dec temp,13]
goto main
error
puts 0,[“I2C Error:”,dec i2cerror,13]
goto main