Name:
readi2c
Syntax:

READI2C (variable,...)

READI2C location,(variable,...)

Location - is a optional variable/constant specifying a byte or word address.

Variable(s) - receives the data byte(s) read.

Description:

This command is deprecated, please consider using the hi2cin command instead.

The readi2c (i2cread also accepted by the compiler) command read i2c location contents into variable(s).

Use of i2c parts is covered in more detail in the separate 'i2c Tutorial' datasheet.

This command is used to read byte data from an i2c device. Location defines the start address of the data read, although it is also possible to read more than one byte sequentially (if the i2c device supports sequential reads).

Location must be a byte or word as defined within the i2cslave command. An i2cslave command must have been issued before this command is used. If the i2c hardware is incorrectly configured, or the wrong i2cslave data has been used, the value 255 ($FF) will be loaded into each variable.

Applies To:
See Also:
Related Create:
Share:
Print:

Example of how to use DS1307 Real Time Clock

This program will read the current data and time from a DS1307 Real time Clock. Note the data is sent/received in BCD format.

Code Example:
	i2cslave %11010000, i2cslow, i2cbyte	; set DS1307 slave address

main:	readi2c 0,(b0,b1,b2,b3,b4,b5,b6,b7)	; read time and date and debug display
	debug
	pause 2000
	goto main
Copy Code Submit an Example

Submit Your Own Code!

You must be logged in to submit code examples. Login now.