PDA

View Full Version : Multiple I2c Devices



alphaengr
- 9th January 2012, 14:02
Hi,
I need four I2c ports to be used to communicate with four slave I2c devices (having same fixed address tcs3414) using 16F689. For one device it is OK with Busin and Busout. But i am unable to find a way to use multiple devices on same chip. Is there any solution exist using Picbasic Pro.

BH_epuk
- 10th January 2012, 19:44
Hi

This can easly be done in PBP using the I2CREAD and I2CWRITE commands.
The I2C routines in PBP are software based and can be assigned to almost any pin on the PIC, in your case you could use RC0 - RC7 as 4 seperate I2C interfaces.

The manual expalins alot of the function for this http://pbp3.com/downloads/PBP_Reference_Manual.pdf section 5.33 & 5.34, but I'd be more than happy to answer any specific questions you may have.

alphaengr
- 11th January 2012, 06:39
Hi,
Thanks for your reply, i have tried following simple code but getting error for I2Cwrite (I2cRead is OK), please check whats wrong with this code. is there something missing......?

'*********************
Device 16F689
Config FCMEN_ON, IESO_OFF, CPD_OFF, CP_OFF, MCLRE_ON, PWRTE_ON, WDT_OFF, INTRC_OSC_NOCLKOUT,BOR_OFF
TRISC=%00000000


Declare All_Digital = True
Xtal=8



Symbol Dpin PORTC.4
Symbol Cpin PORTC.6


DelayMS 100


main:


I2CWRITE Dpin,Cpin,$72,$80,[$3]
I2CREAD Dpin,Cpin,$72,$80,[$3]




End

Dave
- 11th January 2012, 11:39
This doesn't look like PBP code to me?

BH_epuk
- 11th January 2012, 19:48
Agreed, not picbasic, what version of picbasic are you running?

alphaengr
- 12th January 2012, 04:37
Hi,
Sorry i made a mistake, actually it is proton code and i mixed proton with pic basic. I will try writing in picbasic and will let you know if there is any issue.