0
\$\begingroup\$

I need to use the three available CCP modules (CCP1, CCP2, CCP7) in compare mode simultaneously. They all use Timer1 as reference to compare.

My goal is the following: on every match, for each of them, I want to update the target value and reset Timer1. However, each of them will have a different target.

How can I achieve this? Is it possible to change the comparing Timer?

Any help is very appreciated.

I am working with PIC16F1773 : datasheet

\$\endgroup\$
  • \$\begingroup\$ Need a little clarification. How would this work? Won't Timer1 always reach the smallest target first? If you reset Timer1, the CCP modules with higher values will never be reached. \$\endgroup\$ – John Birckhead Feb 16 '18 at 14:24
0
\$\begingroup\$

To do what you want to do, you should not reset timer1. Instead, when you receive an interrupt from any of the compare modules, write a new value into that compare module equal to the previous value plus the timing interval for that module. The timer will continue on its way and you will get the next interrupt after this interval, and you can repeat the process. Make a similar ISR for each of the three modules. This way, all three modules can use timer1.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.