Gary Warner
Jan 24, 2008, 02:24 PM
Maybe it was because it was late last night, but I can't get the CCP1 to work on a PIC16F628 (pin RB3). I'm sitting here at work driving myself nuts. When I get home, I'll need some new ideas.
What are the configuration steps to setup this CCP1 for capture?
I'm sure it's something I've overlooked like assigning the CCP1 counter to the TMR1 or something like that. When I read CCCP1H and L, I only get "1" which I thought was odd as I was expecting "0" if there was no function of the CCP1.
The freaking datasheet has me bouncing from page-to-page so much, I can't keep track of all the considerations. I'm reading a servo drive pulse width. I'm doing this just to learn the CCP1 capture functions, which I've never used before.
My current PWM reader, used for calibrating the YTV Cycler, uses the interrupt pin RB5 just fine. This CCP1 thing is just a learning experience.
I forgot to say what I'm doing:
1. set the pin RB3 as an input
2. set the CCP1CON to detect low-to-high change
3. poll CCP1 event interrupt
4. store CCP1H and L
5. set the CCP1 to detect high-to-low change
6. clear interrupt flag
7. poll CCP1 event interrupt
8. store new CCP1H and L
9. subtract old from new reading to get reading value
10. basically loops after LCD display
I've omitted all the little bits I use to track changes and such.
After reading a bit, I found I might not be doing this:
CCP1IE : CCP1 Interrupt Enable bit
1 : Enable the CCP1 interrupt
0 : Disable the CCP1 interrupt
I'll need to check if I'm setting this to "1" in the PIE1 reg., but I thought this was only if I wanted a hardware interupt execution of the program.
What are the configuration steps to setup this CCP1 for capture?
I'm sure it's something I've overlooked like assigning the CCP1 counter to the TMR1 or something like that. When I read CCCP1H and L, I only get "1" which I thought was odd as I was expecting "0" if there was no function of the CCP1.
The freaking datasheet has me bouncing from page-to-page so much, I can't keep track of all the considerations. I'm reading a servo drive pulse width. I'm doing this just to learn the CCP1 capture functions, which I've never used before.
My current PWM reader, used for calibrating the YTV Cycler, uses the interrupt pin RB5 just fine. This CCP1 thing is just a learning experience.
I forgot to say what I'm doing:
1. set the pin RB3 as an input
2. set the CCP1CON to detect low-to-high change
3. poll CCP1 event interrupt
4. store CCP1H and L
5. set the CCP1 to detect high-to-low change
6. clear interrupt flag
7. poll CCP1 event interrupt
8. store new CCP1H and L
9. subtract old from new reading to get reading value
10. basically loops after LCD display
I've omitted all the little bits I use to track changes and such.
After reading a bit, I found I might not be doing this:
CCP1IE : CCP1 Interrupt Enable bit
1 : Enable the CCP1 interrupt
0 : Disable the CCP1 interrupt
I'll need to check if I'm setting this to "1" in the PIE1 reg., but I thought this was only if I wanted a hardware interupt execution of the program.