View previous topic :: View next topic |
Author |
Message |
Ants
Joined: 22 Nov 2006 Posts: 2
|
Dual I2C implementation on a PIC using CCS |
Posted: Wed Nov 22, 2006 5:44 am |
|
|
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
|
|
Posted: Wed Nov 22, 2006 1:04 pm |
|
|
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
|
|
Posted: Wed Nov 22, 2006 2:46 pm |
|
|
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
|
|
Posted: Wed Nov 22, 2006 2:58 pm |
|
|
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. |
|
|
|