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

I2C pin config and signal aspects in the ports

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



Joined: 20 Feb 2004
Posts: 59
Location: Brazil

View user's profile Send private message

I2C pin config and signal aspects in the ports
PostPosted: Tue Mar 30, 2004 1:08 pm     Reply with quote

Hi!

I have some problems with i2c master mode comm using a PIC18F452@40MHz and would like to take your thoughts about that.

How do you config the pin for hardware i2c? Output or input?

Datasheet from uChip says both input. In my design, if I set them like these I get a strange CLK signal (slow ramp up of the voltage from 0 to 5V) with 90KHz. If set them to output, the CLK signal looks great, 100khz perfect as expected.

Thanks

Marcus
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed Mar 31, 2004 1:21 pm     Reply with quote

Look in the CCS Help area. It talks about set_tris_c(). You can set the SDA and SCL pins to inputs using this command.

Ronald
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 31, 2004 6:07 pm     Reply with quote

I tested your problem on my demo board, and it worked OK.
I didn't test this with the 4x PLL, because my demo board
is not setup for that. So I ran it at 4 MHz.

The following program produced i2c clock and data signals
with fast rise and fall times. At the start of the program,
I set pins C3 and C4 as inputs.

Code:
#include <18F452.H>
#fuses XT, NOPROTECT, BROWNOUT, PUT, NOWDT, NOLVP
#use delay(clock=4000000)
#use i2c(Master, sda=PIN_C4, scl=PIN_C3, FORCE_HW)

//========================

main ()
{
output_float(PIN_C3);
output_float(PIN_C4);

while(1)
  {
   i2c_write(0x55);
  }

}
mvaraujo



Joined: 20 Feb 2004
Posts: 59
Location: Brazil

View user's profile Send private message

PostPosted: Thu Apr 01, 2004 11:59 am     Reply with quote

PCM Programmer,

And which are the pull-up resistors of your demo board on the i2c lines?

It's even more strange because if I use 10k pull-ups, I have slow ramp-ups, if you use 1k, SDA is fast and clear but a 0.5V positive offset appears on the SCL. Crazy, huh?

I'll figure it out, sooner or later!

Thanks,

Marcus
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 01, 2004 12:28 pm     Reply with quote

1K pullups are out of spec for the i2c bus. For a 5v i2c bus,
the smallest pullup size is 1.6K. So I suggest you use 2.2K
on your demo board. That's a convenient size that you
probably have in your parts cabinet.
mvaraujo



Joined: 20 Feb 2004
Posts: 59
Location: Brazil

View user's profile Send private message

PostPosted: Thu Apr 01, 2004 12:35 pm     Reply with quote

I understand your point. In fact it's not a demo board, it's power monitoring device that I'm design. I'll try out the 2k2 to how it works.

Thanks,

Marcus
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