Code:
#CONFIG __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
__config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
__config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_ON
__config _CONFIG5, _CP_OFF & _CPD_OFF
#ENDCONFIG
DEFINE OSC 32
ANSELB = 0
PinSCL2 VAR PortB.1
PinSDA2 VAR PortB.2
GPIOAdat var byte
GPIOBdat var byte
addr var byte
reg var byte
dat var byte
addr = %01000000 ' $40
; UNCOMMENT EITHER SECTION BANK=0 OR BANK=1 NOT BOTH
;START IOCON.BANK=0
reg = 0
dat = 0
I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat] 'set GPIOA all output
reg = 1
dat = 0
I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat] 'set GPIOB all output
LOOOP:
reg = $12 : GPIOAdat = %00000000
I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOAdat]
reg = $13 : GPIOBdat = %00000000
I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOBdat]
pause 250
reg = $12 : GPIOAdat = %11111111
I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOAdat]
reg = $13 : GPIOBdat = %11111111
I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOBdat]
pause 250
GOTO LOOOP
end ;IOCON.BANK=0
;START IOCON.BANK=1 ; NOT TESTED BANK=1 NOT SUPPORTED IN SIMULATOR
'reg = $A
'dat = %10100000
'I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat]
'reg = 0
'dat = 0
'I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat] 'set GPIOA all output
'reg = $10
'dat = 0
'I2CWRITE PinSDA2,PinSCL2,addr,reg,[dat] 'set GPIOB all output
'LOOOP:
' reg = $9 : GPIOAdat = %00000000
' I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOAdat]
' reg = $19 : GPIOBdat = %00000000
' I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOBdat]
' pause 250
' reg = $9 : GPIOAdat = %11111111
' I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOAdat]
' reg = $19 : GPIOBdat = %11111111
' I2CWRITE PinSDA2,PinSCL2,addr,reg,[GPIOBdat]
' pause 250
' GOTO LOOOP
'end ;IOCON.BANK=1
Bookmarks