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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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.
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.