Well Mike, it works perfectly.
Now the question is what the heck have I been doing the last 6 hours???
Oh well, I'm sure I learned something.
It won't quite work for what I was doing in my real application. My ccpr1L was already zero, I was only using one bit in ccp1con to get the shortest possible pulse and period. But I can just set ccp1con on and off. My earlier code was pure gibberish. Too many pieces of code commented out in case I had to go back an redo something I guess. ccp1con and T2Con are NOT in bank 1. By doing a "bsf T2Con,Tmr2on" in bank one, I was actually setting pr2 to 2, I think. Ugh. Ok, I'm going back and changing that embarrasing mess.
So for me-
To stop PWM-
clrf ccp1con
to start PWM-
movlw b'001100' ; be sure to add any quarter cycle bits wanted
movwf ccp1con ; last 4 bits (1100) set pwm mode to active-high
The sad part is that this is what I tried the first time, but because I had that bogus bank switching code it didn't work so I just kept adding stuff until it did
Now the question is what the heck have I been doing the last 6 hours???
Oh well, I'm sure I learned something.
It won't quite work for what I was doing in my real application. My ccpr1L was already zero, I was only using one bit in ccp1con to get the shortest possible pulse and period. But I can just set ccp1con on and off. My earlier code was pure gibberish. Too many pieces of code commented out in case I had to go back an redo something I guess. ccp1con and T2Con are NOT in bank 1. By doing a "bsf T2Con,Tmr2on" in bank one, I was actually setting pr2 to 2, I think. Ugh. Ok, I'm going back and changing that embarrasing mess.
So for me-
To stop PWM-
clrf ccp1con
to start PWM-
movlw b'001100' ; be sure to add any quarter cycle bits wanted
movwf ccp1con ; last 4 bits (1100) set pwm mode to active-high
The sad part is that this is what I tried the first time, but because I had that bogus bank switching code it didn't work so I just kept adding stuff until it did
Last edited: