Steve, I'm not set up to test right now.
Dave, are you sure you used a BYTE?
I reread the manual and there is nothing for I2CREAD that says CONTROL byte must be a constant.
Robert
![]()
Steve, I'm not set up to test right now.
Dave, are you sure you used a BYTE?
I reread the manual and there is nothing for I2CREAD that says CONTROL byte must be a constant.
Robert
![]()
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Dave, here's my complete code using a 16F877 and MCP23016:
ADCON1 = 7 ' A/D off, all digital
ASM
@ DEVICE PIC16F877, HS_OSC, WDT_OFF, PWRT_ON, BOD_ON, LVP_OFF, CPD_OFF, WRT_OFF, DEBUG_OFF, PROTECT_OFF
ENDASM
define OSC 20
DEFINE I2C_SLOW 1 ' Access I2C device above 8MHz
DEFINE I2C_HOLD 1 ' Permit I2C device to hold clock line low
I2CSCL VAR PortC.3
I2CSDA VAR PortC.4
I2CCTRL con %01000000
I2CLOCB VAR BYTE
I2CWORD VAR WORD
I2CLOCB = $06 ' Set location to IODIR register
I2CWORD = %0000000000000000
i2cWRITE I2CSDA,I2CSCL,I2CCTRL,I2CLOCB,[I2CWORD]
PAUSE 12
I2CLOCB = $00 ' Set location to GPIO register
I2CWORD = %1111111111111111
i2cWRITE I2CSDA,I2CSCL,I2CCTRL,I2CLOCB,[I2CWORD]
end
It doesn't work, and it is using a constant.
I don't understand why either, I had this circuit working a few weeks ago. I'm sure I have something screwed in the code, but I don't see what it can be.
Robert
![]()
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Just a bit more on the code above, the 1st I2CWRITE sets the pins as output, the 2nd turns them all ON.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Bookmarks