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

using delay_ms with 40MHz osc

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



Joined: 12 Sep 2003
Posts: 10

View user's profile Send private message

using delay_ms with 40MHz osc
PostPosted: Wed May 05, 2004 10:10 am     Reply with quote

Hello,
I'm using a 40MHz crystal with the PIC18f6520. I am using the processor to read from a dallas 1-wire temperature sensor (DS18S20). I seem to have communication problems when I use the 40MHz crystal, but if I put in a 4MHz crystal the program works fine. The 1-wire communication is time sensitive and I use delay_us() to get the right timing.

Does anyone know of a problem with delay_us() at very high processor speeds? Or does anyone see what else could be the problem?

mle
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed May 05, 2004 10:47 am     Reply with quote

If you want to run the PIC at 40MHZ you will need to use a 10MHZ crystal and use the HS/PLL option in the oscillator configuration. Pull up the data sheet and read up on the oscillator section on how to do it.

Ronald
prwatCCS



Joined: 10 Dec 2003
Posts: 70
Location: West Sussex, UK

View user's profile Send private message

PostPosted: Wed May 05, 2004 10:56 am     Reply with quote

I was all set to use a PIC18F6720 at 40Mhz - some early info from Microchip suggested it was good to 40Mhz, but then I believe it changed and now they only qualify to 25Mhz. So maybe the 18F6520 is the same.

I am now using the 18F6621 which IS ok for use at 40Mhz.

Check the latest data and errata sheets !!

Of course the comments regarding 40Mhz crystals stand - use 10Mhz xtal and HS/PLL mode. I have used a 40Mhz TTL oscillator source with 18F452 successfully, but not yet with the 18F6xxx devices.

regards
_________________
Peter Willis
Development Director
Howard Eaton Lighting Ltd UK
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed May 05, 2004 2:25 pm     Reply with quote

My bad! After looking closer, at the data sheet, the PIC CAN be driven up to 40MHZ.

If your application is time sensitive, remember that interrupts are not figured into the delay_us() function. So, if you have interrupts happening the delay will be extended while the interrupt is serviced.

Ronald
prwatCCS



Joined: 10 Dec 2003
Posts: 70
Location: West Sussex, UK

View user's profile Send private message

PostPosted: Wed May 05, 2004 4:45 pm     Reply with quote

Have you checked that you have the correct setup ??


For my PIC18F6621 at 40Mhz I use

#define CLOCK_FREQUENCY 40000000
#define FOSC 40
#use delay(clock=CLOCK_FREQUENCY)

Those zeros can be easily mistyped !!
_________________
Peter Willis
Development Director
Howard Eaton Lighting Ltd UK
Ttelmah
Guest







PostPosted: Thu May 06, 2004 2:01 am     Reply with quote

prwatCCS wrote:
Have you checked that you have the correct setup ??


For my PIC18F6621 at 40Mhz I use

#define CLOCK_FREQUENCY 40000000
#define FOSC 40
#use delay(clock=CLOCK_FREQUENCY)

Those zeros can be easily mistyped !!

Beware also the fuses. 40MHz 'clocking', is _only_ supported using EC, or ECIO. For the crystal modes, the PLL has to be 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