View previous topic :: View next topic |
Author |
Message |
pyroboy123
Joined: 11 Mar 2004 Posts: 7
|
Problems with I2C between two PICS. |
Posted: Thu Mar 11, 2004 11:34 am |
|
|
Hi everyone,
I need some help please.
I'm trying to get two PICs to communicate, a 16F877A and a 16F87.
I have the 16F877A set up as master and obviously the 87 as a slave.
My first problem, because nothing works !!!, is that I copied the ex_slave given, and modified it a bit.
I'm just working on the ready functions:
BOOLEAN ext_time_ready() {
int1 ack;
restart_wdt();
i2c_start(); // If the write command is acknowledged,
i2c_stop();
restart_wdt();
ack = 0;
return !ack;
}
This doenst even work. My watchdog timer times out !!!! ???? Why ...
please someone please help me.
Or if you could show me some basic code to get I2C running between my two PICs.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
pyroboy123
Joined: 11 Mar 2004 Posts: 7
|
Did some tests |
Posted: Thu Mar 11, 2004 3:05 pm |
|
|
Ok, I tried doing some basic testing,
I took the WDT out, meaning I declared it as NOWDT in the fuses.
My test is to just do:
i2c_start();
i2c_write(0xa0);
i2c_stop();
Port_A = 0xFF;
Now I have a LED connected on port A.
So basicaly, once done with all the i2c functions, le LED should turn off.
Now I KNOW the probleme is not from a LED malconnection, its an i2c problem.
When launching this, the program freezes, because the LED doesnt turn on.
Someon PLEASE HELP !!!!
Pretty please ? |
|
![](templates/subSilver/images/spacer.gif) |
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Fri Mar 12, 2004 7:30 am |
|
|
Suggestions:
Make sure you don't have the led connected to the open drain output pin of Port A without a pull up resistor to complete the circuit.
Have the code flash the led before going into the I2C test.
Use output_high(..) and ouput_low(..) to drive the led pin for testing.
Make sure you have a while(true); line at the end of your code to stop it from falling into the sleep state. |
|
![](templates/subSilver/images/spacer.gif) |
agrj
Joined: 26 Sep 2003 Posts: 48
|
|
Posted: Fri Mar 12, 2004 10:45 am |
|
|
Hi,
are you using "force_HW" in your master mode? I found a bug in CCS compiler or Microchip (I could not find the right problem) and it didn't work in Master mode and force_hw together.
try to use without this .
thanks
Dinho |
|
![](templates/subSilver/images/spacer.gif) |
pyroboy123
Joined: 11 Mar 2004 Posts: 7
|
NOPE |
Posted: Fri Mar 12, 2004 4:09 pm |
|
|
I think I solved ONE of the problems.
I had set the pins for the I2C as outputs on my slave PIC.
That is why my master chip froze.
I fixed this problem. But I cant get the Slave chip to do anything with the master chip.
The master sends the address and stops.
The slave doesnt ever go in the inrerrupt where I have the Led ON feature. ???? |
|
![](templates/subSilver/images/spacer.gif) |
|