Jump to content
Sign in to follow this  

Recommended Posts

Just a very quick question i expect everybody will know the answer to.

The delay librairies supplied with the compiler, if i use a 20Mhz clock and define this in a #pragma statement, if i then use

delay_s(2); will this give a delay of 2 seconds or are the delay functions defined for a 4mhz clock

ie does the #pragma statement compensate for the faster clock speed and adjust the values in the delay routine automatically

Share this post

Link to post
Share on other sites
Guest Pavel

The code for all delay functions is generated based on the clock rate #pragma. Only if there is no clock rate #pragma in the sources the delay code is generated based on 4MHz clock rate for the PIC targets and 50MHz for SX.




Share this post

Link to post
Share on other sites
Guest Talos

Ah that is what i thought, only it doesnt seem to accept that i have included a #pragma statement


I have this statement:

#pragma CLOCK_FREQ 20000000


but pulsing an led for delay_s(1); the led is on for less than a second. However if i increase the value in delay_s to 5 then the led is on for 1 second


If what you are saying is the pragma statement compensates then is it possible that the above line is being ignored.

Is there a way of checking in the compiled code that this statement is being acknowledged


The pic is a pic16f877 20mhz clock



Share this post

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...