DEFINE LOADER_USED 1
DEFINE OSC 20
DEFINE I2C_HOLD
cmdInch CON $50
clk VAR PORTB.0
dat VAR PORTB.1
devAddr VAR BYTE
regAddr VAR BYTE
d VAR WORD
TRISB = 1
devAddr = $E0 ' device address, default
regAddr = $00 ' command register 0
loop:
regAddr = $00 ' command register 0
I2CWRITE dat,clk,devAddr,regAddr,[cmdInch]
pause 70
regAddr = $02 ' $02 high byte of echo 1, $03 low byte
I2CREAD dat,clk,devAddr,regAddr,[d] ' read echo 1 result into word var d
serout2 portc.6, 16468, [dec d.lowbyte,13,10] ' display address $03 low byte of echo 1
goto loop
END
Melanie,
OK this works. I'm not sure about the I2C_HOLD command, it doesn't work without this. But everything else was only a problem of getting at the low or high byte and/or figuring out what the WRITE and READ command needed.
The manual calls my 'devAddr' the 'control' byte. That confused me, but of course I haven't read anything about I2C in general. So maybe that's the problem.
Thanks Melanie, -- Happy Regards.
Bookmarks