compare mode calculation of ccp module

Status
Not open for further replies.

deepa.malagi

New Member
Hi everybody,

I am using pic16f4585,I have to generate frequency of 28.31Hz signal using compare mode of ccp module.

Please help me how to calculate CCPR1 value, I am not getting how to calculate it.using internal frequency 8MHz.

Please help me..........
 
Why do you need to use CCP? 28.31hz equates to 35.32 ms thats very easy to generate using delays, 17.66ms on 17.66ms off

Cheers Ian
 
Last edited:
CCP compare value = 8Mhz / 4 / 28.31Hz / 2
(note the /2 is needed as you will be toggling the output pin at double 28.31Hz)

therefore;
CCP compare value = 8Mhz / 4 / 28.31Hz / 2 = 35323

Assuming you are using an CCP capture interrupt there will be a small interrupt latency between entering the int routine and actually toggling the output pin, a latency of maybe 10 or 15 PIC instructions, so you need to do;
35323 - 10

Then check it on a frequency meter to fine tune the exact frequency.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…