Menu

using compare function of CCP with interrupts

Help
2015-03-07
2015-03-08
  • Peter Stone

    Peter Stone - 2015-03-07

    Hi All,

    I am having a bit of trouble using the PIC CCP module in GCB.
    I can not seem to get an interrupt happening using the compare function.

    Has anyone managed to get this component working within either a 16F88 or 16F1847.

    I am trying to use a combination of timer 1 interrupts and CCP (compare interrupts) to toggle a port on and off. Essentially a PWM control but across multiple ports simultaneously.

    Using the Timer 1 overflow interrupt to turn on the outputs and the compare interrupt to turn off the outputs.

    The outputs turn on but never turn off, indicating that the compare interrupt routine does not get called.

    Peter.

     
  • kent_twt4

    kent_twt4 - 2015-03-07

    In lieu of someone's posting of code...How about showing us your code? Then we could do a quick look or compile to see what may be missing. Some of these On Interrupt routines (as stated in Help) need a little extra manipulation.

    Since CCP compare function uses Timer1, something has to give here. Either reset (disable) Timer1 overflow to CCP interrupt operation in that interrupt (and vice versa), or use say TMR0 overflow to start the CCP compare interrupt.

     
  • Peter Stone

    Peter Stone - 2015-03-08

    Thanks.

    Got it all sorted out.
    There was actually nothing wrong with my code. I was trying to drive everything too fast and the whole thing ended up being interrupt bound.
    I slowed down the timer and it all sprung to life.

    When I have debugged the rest of the code, I will work out if I need to make it go faster and how I achieve that.

    I did notice while playing around with the 16F1847 that there is not an option on Timer 1 to set the clock source to Fosc/4. On this chip you should be able to select between Fosc & Fosc/4. If you just use Fosc you end up with resolution issues and interoperability issues when using in conjunction with the CCP. Might be worth having a look at this.

    Peter.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.