
Originally Posted by
Sherbrook
Two things I would try.
1. Set SDA and SCL high at start
2. The PCA9532 has a reset pin so after PAUSE 400 get the PIC to reset the PCA9532
Phil
Thanks for the reply! I added both of your ideas to my code, but I still cannot receive an acknowledge from the PCA9532. When I look at my scoped output and the datasheet, it looks like it should work with no problem... The address is correctly clocked out along with the R/W bit... there should be no problem. Anyways here's updated code: More advice will be greatly appreciated! Thanks.
Code:
'****************************************************************
'* Name : i2c comms test with led driver *
'* Author : Cody Finden *
'* Version : 1.0 *
'* Notes : SOFTWARE FOR A 16F887 TO WRITE TO A LED DRIVER *
'* : OVER THE I2C PROTOCOL *
'****************************************************************
#config
__CONFIG _CONFIG1, _HS_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF
__CONFIG _CONFIG2, _BOR40V & _WRT_OFF
#endconfig
DEFINE OSC 20 '20MHz crystal
'DEFINE I2C_SLOW 1
'DEFINE I2C_SCLOUT 1
ANSEL = %00000000 'no analog, all digital!
ANSELH = %00000000
TRISA = %00000000 'all ports output
TRISB = %00000000
TRISC = %00000000
TRISD = %00000000
SDA VAR PORTD.3 'i2c data line
SCL VAR PORTD.2 'i2c clock line
led var portc.5 'led for testing
RST VAR portc.6 'pca9532 reset pin (active low)
addr var byte 'pca9532 address storage var
INIT:
PAUSE 400 'let hardware settle
RST = 0 'reset pca9532
pause 10
SDA = 1 'i2c pins high on startup
SCL = 1
RST = 1 'pca9532 on
'PCA9532 i2c address(7 bits + 1 bit for R/W)
'Slave address is 1100(A2)(A1)(A0) + (R/(/W))
'In my setup A2 is pulled low, A1 pulled low, A0 pulled low
addr = %11000000
MAIN:
' I2CWRITE SDA,SCL,ADDR,[$12,$97,$80,$00,$40,$55,$FA,$00,$00]
I2CWRITE SDA,SCL,ADDR,$06,[$00] 'turn off led 0-3
led = 1 'blink led for feedback
PAUSE 500
I2CWRITE SDA,SCL,ADDR,$06,[$55] 'turn on led 0-3
led = 0
pause 500
goto main
Bookmarks