Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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..........
 
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top