Hi, can anyone help me?

I need to expand the i/0 capabilities of a PIC16F876A and the usual (I supose) is to use an i/o expander like the Philips PCF8574 (or other Manufacturer/Type).

As I am a newcomer to the art of programing microcontrollers I've searched the forum for instances of I2C* and found a lot of usefull information on how to use I2C comunication and related devices.

However, when I tried to use "the real stuff" I found myself in a dead end and the reason probably resides in the errors of understanding the Philips datasheet about PCF8574 and/or the lack of programming skills.


Only for test purposes I've tried to "marry" the PIC16F876A and the PCF8574 with a small PBP program intended to switch on and off 8 leds, PCF has latched outputs, the code looks like this:

DEFINE OSC 10
ADCON1=7
DEFINE I2C_SLOW

TRISA=%00000001

SCL VAR PORTA.1 ' 4k7 pull-up
SDA VAR PORTA.0 ' 4k7 pull-up


start:

I2CWRITE SDA,SCL,%01000000,[%11111111] leds ON
PAUSE 5000

I2CWRITE SDA,SCL,%01000000,[%00000000] 'leds off
pause 5000

goto start

end


Ok! At this moment you can lough if after reading the code above I think it could work!


I´ve watched the PIC pins with my osciloscope and found that each five seconds both SDA and SCL generates a " signal burst" to ground.

I realise that something is wrong with the code (or the way I'm missing something in the PCF datasheet) because the leds remain as they came from the store and even when I disconect the leds I found (with osciloscope) that the logic level present at PCF i/o pins is somewhere between low and high and at each 5sec they reach high logic level.

Sorry about my english, thanks for reading
NOMADA