PDA

View Full Version : Need Help on PCA9555 communication



naidab
- 13th November 2007, 01:20
Hi Guys, Does anyone have a sample or idea how this PCA955 chip works? I had viewed it's datasheet it is using 16BitI2C communication any sample code you have there in pbp? It would be a great help.


Thanks in Advance

paulvits
- 13th November 2007, 07:36
Hello,

This is a working example that I used earlier.
4 PCA9555 were used on adress 0,1,2,3 as you will find back in the code.



'************************************************* ***************
'* Name : PCA9555.BAS *
'* Author : Vits Paul *
'* Notice : Copyright (c) 2004 *
'* : All Rights Reserved *
'* Date : 12/16/2004 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
DEFINE LOADER_USED 1

Include "Modedefs.Bas"
DEFINE HSER_BAUD 9600
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
' Set LCD Data port
DEFINE LCD_DREG PORTB
' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_DBIT 4
' Set LCD Register Select port
DEFINE LCD_RSREG PORTC
' Set LCD Register Select bit
DEFINE LCD_RSBIT 4
' Set LCD Enable port
DEFINE LCD_EREG PORTC
' Set LCD Enable bit
DEFINE LCD_EBIT 5
' Set LCD bus size (4 or 8 bits)
DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
' Set command delay time in us
DEFINE LCD_COMMANDUS 2000
' Set data delay time in us
DEFINE LCD_DATAUS 50

'define I2C
SCL VAR PORTB.1
SDA VAR PORTB.2



' Define program variables

x1 var byte
x2 var byte
n var byte

OPTION_REG.7 = 0 ' Enable PORTB pullups

ADCON1 = 7 ' Make PORTA and PORTE digital

i2cwrite SDA,SCL,%01000000,%00000110,[0,0] 'Adres0 write to configuration register place 6 all output
pause 10
i2cwrite SDA,SCL,%01000010,%00000110,[0,0] 'Adres1 write to configuration register place 6 all output
pause 10
i2cwrite SDA,SCL,%01000100,%00000110,[0,0] 'adres2 write to configuration register place 6 all output
pause 10
i2cwrite SDA,SCL,%01000110,%00000110,[0,0] 'adres3 write to configuration register place 6 all output
pause 10
Lcdout $fe, 1, "test PCA9555" ' Display sign on message
PAUSE 10

loop:
x1 = 3
x2 = 192
for n = 1 to 8

i2cwrite SDA,SCL,%01000000,%000000010,[x1,x2]
i2cwrite SDA,SCL,%01000010,%000000010,[x2,x1]
i2cwrite SDA,SCL,%01000100,%000000010,[x1,x1]
i2cwrite SDA,SCL,%01000110,%000000010,[x2,x2]
pause 10
x1 = x1 * 2
x2 = x2/2
Lcdout $fe, 1, "LOOP",dec n
pause 100
next n
x1 = 192
x2 = 3

for n = 1 to 8

i2cwrite SDA,SCL,%01000000,%000000010,[x1,x2]
i2cwrite SDA,SCL,%01000010,%000000010,[x2,x1]
i2cwrite SDA,SCL,%01000100,%000000010,[x1,x1]
i2cwrite SDA,SCL,%01000110,%000000010,[x2,x2]
pause 10
x2 = x2 * 2
x1 = x1/2
Lcdout $fe, 1, "LOOP",dec n
pause 100
next n
goto loop


End

naidab
- 13th November 2007, 11:58
Thanks for your generous help, I will try it asap.