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 question

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



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

I2C question
PostPosted: Thu Apr 01, 2004 9:50 pm     Reply with quote

In a project I'm using the Hardware I2C (PIC16F876,pCM3.185) to talk to a Phillips Frontend PAL tuner. A couple of days ago I got a few samples back from the manufacturer. The problem is on some of the boards the hardware I2C doesn't work. If I take the FORCE_HW out of my #use I2C definition aand make it a software I2C then everything works fine, but when I put it back in there it fails again. And as I said this happens only on some of the boards. I'm sure the PICs are not faulty because I tried changing them around but it didn't help. Does anybody know why this is happening? My pull-ups are 3.9k.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 01, 2004 11:11 pm     Reply with quote

What i2c bus speed are you using ? The default speed ?
or fast mode ?
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Thu Apr 01, 2004 11:41 pm     Reply with quote

This is my I2C definition:

#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3)//,FORCE_HW)

I can't recall if I tried it without the FAST or not. Could this be the problem?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 1:23 am     Reply with quote

Years ago, I noticed that the 16F87x series had a problem with
hardware i2c. It seemed to me that the duty cycle of the
SCL waveform was reversed from the way that Philips wanted
it to be. Philips would prefer that it be low for a longer period
than it is high. But Microchip has it reversed. So it may not
meet spec for the Philips chip that you're using. That's a
possibility, anyway. You can check it with a scope.

Also, what's the crystal frequency that you're using for the PIC ?
I haven't measured it lately, but historically for software i2c,
the CCS library functions produced a SCL clock frequency that was
much slower than the nominal values of 100 KHz and 400 KHz.
(ie., something like 40 KHz in Slow mode, if you used a 4 MHz crystal).
So that could be a clue. When you go to software i2c, you may
simply be running everything more slowly and perhaps the Philips
chip likes that.

I would check your resistors and make sure they're really 3.9K
and not 39K.

What is the actual p/n of the Philips chip that you're using ?
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 1:55 am     Reply with quote

Thanks PCM, interesting information about the hardware I2C. I was not aware of that.
My crystal is 4MHz and I've already made sure all my pull-ups are 3.9k.
I wonder why this is happening only on some of the boards...?

I'm using the I2C to communicate with the following parts:

Phillips FQ1216ME-MK3 PAL Tuner
or
Temic Telefunken Frontend 4006FH5 PAL Tuner

Their datasheets don't mention what I2C driver chips they use inside.
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Sun Apr 04, 2004 2:11 am     Reply with quote

Ok, I commented out the #USE I2C statement and coded all the I2C routines in pure assembly using the hardware module (it was actually a lot of fun). I tried it on one of the problematic boards and it worked. When I tried the #USE I2C (with FORCE_HW) again on the same board it failed (a software I2C still worked too).
It seems something is marginal in the hardware implementation of the CCS #USE I2C. The question is, how things can be marginal when it is using a hardware module?
blaker
Guest







PostPosted: Sun Apr 04, 2004 3:18 pm     Reply with quote

I'm also working with some phillips rf chips. Mine is the TEA5768HL.

In the datasheet for the chip it says make sure you use an i2c speed < 400kHz. I imagine there are similar constraints for your chip.

Have you tried force hardware and SLOW?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 04, 2004 3:50 pm     Reply with quote

They must be doing something differently than you are.
You could look at the .LST file for the CCS routines and
compare it to your routines and check for differences.

Before CCS had their own hardware routines, I ported some
code to CCS that was originally done by Julian Winpenny for
the C2C compiler. It's here:
http://www.ccsinfo.com/wwwboard/messages/725.html
The low level i2c routines are near the end of that post.
Maybe that code would work. But since you have working
ASM code, you may not need to experiment further.

I searched for that Philips part number on their website,
http://www.semiconductors.philips.com/cgi-bin/search/search.pl
and couldn't find it. Do you have a link to the data sheet ?
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Sun Apr 04, 2004 7:04 pm     Reply with quote

I'll probably use slow software I2C just to be safe. I don't want the units fail in the field and I can live with the code/performance overhead.

Here is the address to the tuner page. However it doesn't include any links to the datasheet, I had to email their customer service and request it.
http://www.business-sites.philips.com/Assets/Downloadablefile/FM_FQ_leaflet-735.pdf

The datasheet doesn't say anything about I2C speed.

If you think this part may be useful to you in the future just let me know and I'll send you the datasheet.
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