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

Strange behaviour I2C with 16F876

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
h.a.j.molenaar



Joined: 04 May 2005
Posts: 9

View user's profile Send private message

Strange behaviour I2C with 16F876
PostPosted: Thu Aug 09, 2007 5:02 am     Reply with quote

Hi all,
Encountering a strange behaviour using I2C with a 16F876 (has hardware I2C).
When I use:
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3) so with software bit-banging everything works fine.

On the other hand when I use:
#use i2c(Master,FORCE_HW,FAST = 3686400, sda=PIN_C4,scl=PIN_C3)
so using the hardware I2C, the micro is clocked with 3.6864 Mhz then
the SCL pin is pulled to ground and the program hangs. SDA remains high.
Both pins have a pull-up to Vdd.

Have anyone experience with this, regards Hugo.
ckielstra



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

View user's profile Send private message

PostPosted: Thu Aug 09, 2007 5:38 am     Reply with quote

Code:
#use i2c(Master,FORCE_HW,FAST = 3686400, sda=PIN_C4,scl=PIN_C3)
You want to clock the I2C with 3.68MHz? Isn't that a bit fast?
The fastest clock you can select for I2C is Fosc / 4. According to Table 15-9 of the datasheet you have to clock the PIC at a minimum of 1.5MHz to meet the 100kHz mode specifications and 10MHz or higher to meet the 400kHz mode specifications.
h.a.j.molenaar



Joined: 04 May 2005
Posts: 9

View user's profile Send private message

PostPosted: Thu Aug 09, 2007 6:03 am     Reply with quote

It is in intended to use 400Khz bus speed.

It is not clear to me how to specify the fast = xxxx parameter.
ckielstra



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

View user's profile Send private message

PostPosted: Thu Aug 09, 2007 6:23 am     Reply with quote

With the fast parameter you specify how 'fast' you want the clock speed to be.

Code:
#use i2c(Master, FORCE_HW, FAST=400000, sda=PIN_C4, scl=PIN_C3)
This sets the target speed to 400kbps
h.a.j.molenaar



Joined: 04 May 2005
Posts: 9

View user's profile Send private message

PostPosted: Thu Aug 09, 2007 7:09 am     Reply with quote

Hi, I already did it after your formet comment but the strange behaviour still occurs. I am going to setup another device may be the hardware has been damaged.
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