CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Dual I2C implementation on a PIC using CCS

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ants



Joined: 22 Nov 2006
Posts: 2

View user's profile Send private message

Dual I2C implementation on a PIC using CCS
PostPosted: Wed Nov 22, 2006 5:44 am     Reply with quote

Has anyone ever successfully implemented dual I2C on a PIC using CCS?

I need to have my PIC (16F876A) behaving as a slave (using the hardware periferal) on one I2C network, and as a master (using bit-banging) to communicate with EEPROMS on a second network.

I can get each network working independantly using, for the slave mode "#use i2c(slave, SDA=PIN_C4, SCL=PIN_C3, FORCE_HW)" and for the master mode "#use i2c(master, SDA=PIN_C6, SCL=PIN_C7)".

I noted in the example program for dual RS232 comms (CCS help) it should apparently be possible for I2C too, but something in the bit-banging one seems to force the hardware Dat/Clk pins to output state, hence locking up that I2C network (for all other devices on it)

Or should I truly bit-bang the EEPROM network myself, leaving out CCS "#use i2c" for that part?

Any clues?
jma_1



Joined: 08 Feb 2005
Posts: 147
Location: Wisconsin

View user's profile Send private message

PostPosted: Wed Nov 22, 2006 1:04 pm     Reply with quote

I have not tried implementing I2C on two ports.

If the breakdown of the communication is setting up the hardware correctly, this hopefully is relatively easy to fix. Please post sample code with both I2C ports defined. Try viewing the LST file and see how/where the registers are setup for the S/W master. Perhaps the compiler is 'resetting' the I2C for the hardware port (side effect). Try switching the order in which the ports are defined.

These are only suggestions on where to look for the problem.

If you do not have time to debug the setup, alternate pic's are available with 2 dedicated hardware i2c/spi ports (18F45J10, etc). This more likely a bad suggestion if you have already chosen a micro and prototyped your application.

If debugging the software does not work, can you use the on-board 256 bytes of EEPROM?

JMA_1
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Nov 22, 2006 2:46 pm     Reply with quote

I've done something like this before. I had a 18F452 acting as a master and would talk to 10 16F76 PICs that were acting as slaves. Each of these 16F76 parts would, in turn, talk to a RH/Temp sensor (SHT15). I would bit-bang the signals to the sensor and use the onboard I2C hardware for the Slave portion.

Ronald
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Nov 22, 2006 2:58 pm     Reply with quote

Quote:

But something in the bit-banging one seems to force the hardware Dat/Clk pins to output state

Post your version of the compiler.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group