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

PIC16F1455 USB and I2C problems

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
xiaop@lsbu.ac.uk



Joined: 18 Apr 2018
Posts: 5

View user's profile Send private message

PIC16F1455 USB and I2C problems
PostPosted: Tue Nov 13, 2018 4:34 am     Reply with quote

I am working with PIC16F1455, I have got both USB and I2C working separately, but not together, it boils down to one problem, clock:

For USB I have to set
#use delay(clock=48000000)

For I2C I have to set
#use delay(clock=8000000)

Is any solution for this?
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Tue Nov 13, 2018 7:38 am     Reply with quote

Why on earth do you 'have to set' the clock to 8MHz for I2C....

You can set the I2C baud rate in it's setup.

It sounds as if possibly you are using the I2C without setting it's rate, which then means it defaults to 'as fast as possible', which would then give problems when you clock at 48MHz.

A typical I2C setup, would be:

#USE I2C (FAST=400000, I2C1, MASTER)

Using the hardware port at 400KHz.

I'm using this on a chip running at 120MHz.....

In your case, I think the chip only has software I2C, but the same applies. Just work out the rate that is working, and specify this when you switch to the higher CPU clock.
temtronic



Joined: 01 Jul 2010
Posts: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Nov 13, 2018 7:58 am     Reply with quote

I was curious...watching snowflakes here.... that PIC does have HW I2C however the 'clock' has to be setup correctly. You should specify 'internal' if using the internal RC oscillator of the PIC.
Perhaps the version of your compiler defaults to it, but you should never assume it does what you think....

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Tue Nov 13, 2018 9:21 am     Reply with quote

Also, as a comment, just because you are using USB, you don't have to run the CPU at 48MHz.

The clock _feeding_ the USB needs to be at 48MHz, but the CPU can run at a division from this. So it can still run at 8, 16, or 24MHz if required.

If he is using the internal oscillator and USB, he needs ACT=USB in the clock setup, otherwise the clocking will not be accurate enough for reliability.
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