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 support@ccsinfo.com

I2C problems / 16f877a / ccs c 3.222

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








I2C problems / 16f877a / ccs c 3.222
PostPosted: Thu Jul 28, 2005 4:18 pm     Reply with quote

the i2c functions does not work at all, with software or hardware interface, the connected pins are powerless, nor 0 or 1.

What to do?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 28, 2005 5:17 pm     Reply with quote

Quote:
the i2c functions does not work at all, with software or hardware
interface, the connected pins are powerless, nor 0 or 1.

Not true. I tested the following program with PCM vs. 3.222
with a 16F877A on a PicDem2-Plus board and it worked OK.
Here's the output displayed on my terminal window:
Quote:
Start
55 aa

That test was with software i2c. I then edited the 24256.C driver file
to make it use hardware i2c, by changing the #use i2c() statement to:
Quote:
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL, FORCE_HW)

It worked again. Here is the test program:
Code:
#include <16F877A.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#define EEPROM_SDA  PIN_C4
#define EEPROM_SCL  PIN_C3

#include <24256.c>

//=====================================
void main()
{
printf("Start\n\r");

init_ext_eeprom();

write_ext_eeprom(0, 0x55);
write_ext_eeprom(1, 0xAA);

printf("%x  ", read_ext_eeprom(0));
printf("%x", read_ext_eeprom(1));


while(1);
}
Ttelmah
Guest







PostPosted: Fri Jul 29, 2005 4:11 am     Reply with quote

One obvious commet applies. The poster is presumably aware that the I2C pins are driven to emulate open-collector outputs, and a pull-up resistor is needed on each line?. The pins will default to the 'undriven' state, with the lines floating.

Best Wishes
Guest








PostPosted: Fri Jul 29, 2005 1:26 pm     Reply with quote

i know about the resistors ... however, i got some bit banging routines
and now its working without the i2c support in ccs.

thanks anyway.
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Fri Jul 29, 2005 2:26 pm     Reply with quote

I addressed this question before in:

http://www.ccsinfo.com/forum/viewtopic.php?t=23221&highlight=i2cstart+bug

Try upgrading to 3.223
I don't know why it works with some people and not with others.

I asked CCS what is was the bug in before 3.223, since I did experience occasional i2c_write() errors following an i2c_start().
I never got a response, so i figured i'd write my own MSSP-based master routines.

Maybe i should try the latest version and see if my previous problem disappears.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jul 29, 2005 2:50 pm     Reply with quote

CCS admits there was a problem with i2c -- I assume in vs. 3.222.
From their versions page:
Quote:
3.223 A problem with I2C_START() on some parts is fixed

They didn't say what PICs are affected, so that's why I tested his PIC,
a 16F877A, in hardware, with both software and H/W i2c.

He didn't give his application circuit, but I suspect that he may have
been using the CCS eeprom driver. It defaults to using pins B1 and B0.
If you want to use the hardware pins (for most 40-pin chips), you have
to place the new pin definition statements above the #include line for
the driver, like this:
Code:
#define EEPROM_SDA  PIN_C4
#define EEPROM_SCL  PIN_C3

#include <24256.c>

If you don't do that, the i2c will come out the wrong pins and give
the impression that "i2c doesn't work".

I didn't mention this because he was adament that it "didn't work",
and if that's how he feels, then I'm not going to push it.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Fri Jul 29, 2005 3:51 pm     Reply with quote

PCM programmer wrote:
above the #include line for
the driver, like this:
Code:
#define EEPROM_SDA  PIN_C4
#define EEPROM_SCL  PIN_C3

#include <24256.c>




That's one of the niftiest tips I've seen yet!! I just edit the driver for the pins I'm using, but daisy-chaining the defines is about five times as elegant.

Scott
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