Hey Dave,
Im trying to use 16f877a with macp23017, but I wasn't successful.
I define the mcp23017 register, but when I want to compile my program it gives me error.
I tried to use your program and learn from it but I had no success, I noticed you are using some include file that I dont have them.
I have 16 led on each port would you please help me?
Code:
'* Notes : XT 4Mhz *
'* : *
'****************************************************************
'Includes
include "modedefs.bas"
'****************************************************************
'Definitions
DEFINE I2C_SDA PORTc,4
DEFINE I2C_SCL PORTc,3
'****************************************************************
'Variables
a var byte
chip1 var byte
chip2 var byte
chip3 var byte
chip4 var byte
'****************************************************************
'Alias
CP VAR PORTc.3
DP VAR PORTc.4
'****************************************************************
'Initialization
'Pic 16f877A
option_reg.7 = 0 'portb pullups enabled
SSPSTAT=%00111101
'SSPCON1=%00101111
SSPCON2=%00000001
'MCP 23017
IODIRA Con $00
IODIRB con $00
IPOLA con $00
IPOLB con $00
GPINTENA con &00
GPINTENB con $00
DEFVALA con $00
DEFVALB con $00
INTCONA con &00
INTCONB con &FF
IOCON con %00001000
GPPUA con $00
GPPUB con $00
INTFA con $00
INTFB con $00
INTCAPA con &00
INTCAPB con &00
GPIOA con $00
GPIOB Con $FF
OLATA con $00
OLATB con &FF
'****************************************************************
'set ports
trisa=%00000000
trisc=%00000000
pause 500
goto start
start:
porta.5 = 1
portc.7=0
pause 500
porta.5 = 1
portc.7=1
pause 500
I2CWRITE dp,cp,$00,chip1,[%00000000] 'one-shot sample
pause 200
I2CWRITE dp,cp,$00,chip1,[%11111111] 'one-shot sample
pause 200
I2CWRITE dp,cp,$00,chip1,[%00000000] 'one-shot sample
pause 200
I2CWRITE dp,cp,$00,chip1,[%11111111] 'one-shot sample
pause 200
goto start
end
Bookmarks