Well I figured out the I2Creadfor the initialization. The slave address byte should be: %11000000 and not %01100000. So good but no matter what register I read from ($00 to $0C) I get zeros. I think I know the problem but don't have a fix. From research I understand that the VCNL4040 can't have a stop bit from the master
between a I2CWRITE & I2CREAD. So when I switch from a write to a read (as shown below) I get zeros from $08 register.
I2Cwrite PORTC.4,PORTC.3,%11000000,%00001000 '$08
pause 5
I2Cread PORTC.4,PORTC.3,%11000000,[PS_DATA_L,PS_DATA_H]
PAUSE 5
The data sheet shows this format to read register $08 instead of just a I2CREAD. There fore when the I2CWRITE finishes I get a stop bit from master and the data sheet shows to use no stop from master between the Write & READ.
Any ideas how to get around this with out writing my own I2C statement?
Thanks
Bookmarks