Robert,Originally Posted by Demon
we don't want to guess anymore, please post your full code and schematic.
Robert,Originally Posted by Demon
we don't want to guess anymore, please post your full code and schematic.
Last edited by Demon; - 4th October 2016 at 19:14.
regards
Ralph
_______________________________________________
There are only 10 types of people:
Those who understand binary, and those who don't ...
_______________________________________________
'define LOADER_USED 1
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 LCD_DREG PORTA
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 4
define LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
DEFINE I2C_SLOW 1
DEFINE I2C_HOLD 1
I2CSCL VAR PortD.1
SDAISW1 VAR PortC.2
LOCGPIO CON $00
LOWWORD CON %0000000000000000
I2CCTRL VAR BYTE
I2CLOCB VAR BYTE
I2CWORD VAR WORD
CTRLIOW CON %01000000
CTRLIOR CON %01000001
GOTO START ' Bypass subroutines
'--------------------------- SUB-ROUTINES ----------------------------
RDISW1:
I2CREAD SDAISW1,I2CSCL,I2CCTRL,I2CLOCB,[I2CWORD]
PAUSE 12
RETURN
'-------------------------- MAIN PROGRAM -----------------------------
START:
PAUSE 2000
LCDOUT $FE,1,"Program start"
CYCLE:
I2CCTRL = CTRLIOW
I2CLOCB = LOCGPIO
I2CWORD = LOWWORD
GOSUB RDISW1
I2CCTRL = CTRLIOR
GOSUB RDISW1
LCDOUT $FE,$94,BIN16 I2CWORD
GOTO CYCLE
END
Circuit coming up.
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!
Circuit:
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!
I tried reading from the INTCAP instead of the GPIO with much better results.
Got more tests to do.
EDIT: Nope, not that, nevermind...
Robert
![]()
Last edited by Demon; - 23rd October 2005 at 23:44.
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!
Robert,
As I'm not using the MCP23016 I haven't read the entire datasheet.
But looking at your schematic there is one thing that may cause strange effects:
you have switches to VDD, but no PullDown Resistors.
So when the switches are open the MCP's inputs are floating.
(I would prefer to have the switches connected to GND and have PullUps to VDD)
I
regards
Ralph
_______________________________________________
There are only 10 types of people:
Those who understand binary, and those who don't ...
_______________________________________________
ARGH!
Thanks Ralph! I can't believe I missed that. Pull-up resistors is one of those things that I watch out for in all switches.
But I've been so busy learning new stuff on this circuit that I've totally forgotten what I consider to be a basic thing. I was so sure I had misunderstood something in the MCP23016 datasheet, or wired an I2C device improperly, a pull-up resistor never dawned on me.
The circuit works beautifully now.
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!
Bookmarks