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.

Any PICs w/ two CCP modules, each with independent timers

Status
Not open for further replies.

pdfruth

New Member
I'm wondering if anyone knows of a PIC variant that has two CCP modules, each with it's own independent 16 bit timer. Most all of the PICs [I've looked at thus far] that have two CCP's, are all based on a common 16 bit timer (Timer1 in all the 16Fxxx family members).

I've been using microchip's product selector filter tool to see if I can narrow the field, but don't seem to be able to get anywhere. Or maybe it's just because such a thing doesn't exist.

Why, you ask....
- I want to use one CCP module's "capture" mode to capture the cycle time of an input frequency.

- Then, periodically take a snapshot of a "capture", and calculate a percentage of that cycle time. (i.e. 5%). Note: The input frequency is no fixed. It will vary over time. So this sampling will occur on a very frequent basis.

- Based on that calculation, I want to use the other CCP module's "compare" mode to output a modified version of the input frequency. Say a frequency who's cycle time is 105% of the input frequency.


For bonus points.... can you guess what application I'm targeting?
 
Last edited:

Pommie

Well-Known Member
Most Helpful Member
Why can't they both use the same timer? You then capture a certain number of timer cycles and output be setting a compare value.
For example, if you are getting pulses of 1mS and your timer is running at 1MHz then each interrupt your timer will have gained 1000. Take this time, scale it and add the current timer value to get the compare value.

Is this a speedo corrector?

Mike.
 

pdfruth

New Member
Pommie said:
Why can't they both use the same timer? You then capture a certain number of timer cycles and output be setting a compare value.
For example, if you are getting pulses of 1mS and your timer is running at 1MHz then each interrupt your timer will have gained 1000. Take this time, scale it and add the current timer value to get the compare value.

After posting, and noodling on it for a bit (whilst sitting on plane for a few hours).... I had an ah-ha moment.
Sure, just like you said, I think that'll work.
Thanks, Mike.

Pommie said:
Is this a speedo corrector?
You are correct sir! Have your self an adult beverage, on me. :D
 

Blueteeth

Well-Known Member
You could use the CCP module to capture, then just output a PWM in software..assuming that is all you want the PIC to be doing... After all, once setup the capture mode of the CCP will just generate an interupt...so unless you're dealing with high frequency here (>3khz) it can all be done. Sometimes it can be annoying when certain peripherals 'share' hardware, but there is almost always a way around it..

Blueteeth

ps. was my post pointless? just re-read, looks so :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Top