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 and clock frequency

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








i2c and clock frequency
PostPosted: Tue Mar 03, 2009 2:07 pm     Reply with quote

Hi all.
After spending 2 days trying to understand why my PIC16F88 didn't want to talk to a 4-digit LED driver with I2C bus (Philips SAA1064), I reduced the clock frequency from 8Mhz to 4Mhz and it started working like a charm.

The PIC is configured to use the internal clock and I know this can be an issue with asynchronous protocols, because usually the internal clock may not be accurate, but I was quite surprise to have problems with the I2C protocol.

Or maybe using the internal clock is not a problem but its frequency was too high. I am a bit confused. I am happy with the PIC working at 4Mhz, I was just trying to figure out the reason it didn't work at 8Mhz.

Anybody has any idea?
Ttelmah
Guest







PostPosted: Tue Mar 03, 2009 3:10 pm     Reply with quote

What frequency are you selecting for the I2C?.
You can set this in the use I2C defintion, by specifying a speed, so:

FAST=125000

Are you using software, or hardware I2C?.
This affects the limits on the speed for a given clock rate.
So (for instance), you specify the default 'fast' rate (400KHz), but the compiler will give you the fastest it can manage _below_ this rate. With the software, probably only about 100KHz. With the 4MHz clock this will halve.
What frequency is the device rated for?.
What value pull-ups are you using?.
How long is the bus?.

The speed that I2C supports depends first on the speed rating of the device, but then primarily on the bus capacitance, and the value of pull-up being used. If you are using relatively large pull-ups, the bus may well only have a few tens of KHz.

Best Wishes
ccesaretto



Joined: 03 Mar 2009
Posts: 5

View user's profile Send private message

PostPosted: Tue Mar 03, 2009 3:49 pm     Reply with quote

I haven't set any frequency for the I2C bus.
My understanding is that the PIC16F88 has no hardware master I2C so I would say I am using a software master I2C.

I can't find any information in the data sheet about the maximum operating frequency of the LED driver or about its capacitance. The length of the bus is very short, about 15 cm and I am using 1 KOhm resistors for the pull-ups.

I am going to try to set the clock back to 8 MHz and the bus speed to a lower value. It may be possible the default bus speed is proportional to the clock frequency and the one I get with a clock set to 8 MHz is just to high for the device I am trying to drive.

I will post the results of my tests.

Thank you for your time.
ccesaretto



Joined: 03 Mar 2009
Posts: 5

View user's profile Send private message

PostPosted: Tue Mar 03, 2009 4:05 pm     Reply with quote

Test done.

With the clock set at 8 Mhz, the I2C bus works if I set the parameter

FAST=50000

At 60000 it already doesn't work.

With the clock set at 4 MHz, I was able to set much higher values.

I keep investigating...
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Mar 03, 2009 5:12 pm     Reply with quote

ccesaretto wrote:
My understanding is that the PIC16F88 has no hardware master I2C so I would say I am using a software master I2C.
The PIC16F88 has hardware I2C on pins RB1 and RB4.

The SAA1064 is an old chip (1991) so I expect it will only support the Standard Mode with a maximum speed of 100kbit/s.

What is the value of your pull-up resistors?
What length is your bus?
Kenny



Joined: 07 Sep 2003
Posts: 173
Location: Australia

View user's profile Send private message

PostPosted: Tue Mar 03, 2009 11:44 pm     Reply with quote

The 16F88 has hardware for only an i2c slave (SSP) so it's bit banging I'm afraid.

The clock speed never reaches 100kHz regardless of the settings. With 8MHz it gets to about 83kHz, and when FAST = 50000 is added it drops to about 77kHz. At the higher frequency the clock for the 9th bit looks to be too soon (<10uS) after the one for the 8th bit.

BTW Not related to your problem I think but 1K ohm is too low for the pullup resistors. 2K2 is better.
Ttelmah
Guest







PostPosted: Wed Mar 04, 2009 3:17 am     Reply with quote

OK. So you have your answer. The device only currently supports about 50K, and at 4Mhz, your processor gives below this, whatever you select. At 8MHz, the default (which will be trying to get 100K), goes above this critical frequency, and it stops working.

It may actually be that your pull-ups are too low for the device. The PIC won't mind driving 'low' pull-ups, but the _minimum_ specified value for the pull up resistors, for a 'standard mode (100KHz nominal) I2C device, with 5v supply, is 2KR (using no series resistor). I actually wonder if the LCD, is a 100KHz standard mode device, that is not giving it's proper speed, because the bus is overloaded. I second the suggestion to try 2K2, which is the normal 'lowest' pull-up used.

Best Wishes
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