Problem with delays when using HSPLL

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Problem with delays when using HSPLL

Post by CharlieM » Thu Mar 24, 2011 11:19 pm

Hello Everyone,

Working on a project using a 18F8722 and I have a 10 mhz osc. If I declare the clock = 10 and enable hspll my delays are way off. I tested this my flashing a led. I turned it on for 50 ms and off for 50 ms. shoud'nt it flash at the same rate regardless of how fast the pic is running?
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Thu Mar 24, 2011 11:21 pm

I have it sorted. Thanks.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Post by octal » Fri Mar 25, 2011 6:28 am

when you enable the HSPLL you got a x4 freq, you need to define the clock as a 40MHz (not 10 Mhz). SF calculate the delays taking into account the true core frequency, not the external crystal value.

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Fri Mar 25, 2011 9:51 am

Hi Octal thanks. that is what I did and all is working fine.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

Jon Chandler
Registered User
Registered User
Posts: 185
Joined: Mon Mar 10, 2008 8:20 am
Location: Seattle, WA USA
Contact:

Post by Jon Chandler » Fri Mar 25, 2011 12:42 pm

I think people get confused with the CLOCK statement. It doesn't CONTROL anything. It simply INFORMS the software how fast it's running and the software uses it to calculate all the time-related values.
Jon

Check out the TAP-28 PIC Application board at http://www.clever4hire.com/throwawaypic/

Post Reply