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

Problems with I2C between two PICS.

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



Joined: 11 Mar 2004
Posts: 7

View user's profile Send private message

Problems with I2C between two PICS.
PostPosted: Thu Mar 11, 2004 11:34 am     Reply with quote

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
pyroboy123



Joined: 11 Mar 2004
Posts: 7

View user's profile Send private message

Did some tests
PostPosted: Thu Mar 11, 2004 3:05 pm     Reply with quote

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 ?
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Fri Mar 12, 2004 7:30 am     Reply with quote

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.
agrj



Joined: 26 Sep 2003
Posts: 48

View user's profile Send private message

PostPosted: Fri Mar 12, 2004 10:45 am     Reply with quote

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
pyroboy123



Joined: 11 Mar 2004
Posts: 7

View user's profile Send private message

NOPE
PostPosted: Fri Mar 12, 2004 4:09 pm     Reply with quote

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. ????
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