-
16F88 PWM troubles
Hi All,
Sorry to bother evryone for such a simple question. I tried to search the archives, but when I entered "16F88+PWM" I was told that "PWM" was too small or too common to be included in the search.
Anyway, while I have done it before, I can't get the PWM to work on a 16F88. Here is what I am trying:
@ DEVICE PIC16F88,HS_OSC,MCLR_ON,LVP_OFF,WDT_OFF,PROTECT_OF F
DEFINE OSC 20
TRISB = 255
CMCON = 0
ADCON0 = 0
ANSEL = 0
PR2 = 122
CCPR1L = 64
T2CON = %00000100
CCP1CON = %00001100
output portb.3
end
Any ideas why this isn't working? As far as I remember, this was a working snip.
Thanks,
Jonathan
-
jpeakall, you have the port direction register set for all inputs.....
Dave Purola,
N8NTA
-
Dave,
I have tried it the other way, as outputs. I guess that was still in there from me threshing around and trying everything I could think of.
Thanks, see anything else?
Jonathan
-
your code will work if you change End by Here: goto Here
here's the fix
Code:
@ __CONFIG _CONFIG1, _CCP1_RB0 & _DEBUG_OFF & _LVP_OFF & _BODEN_ON & _MCLR_ON & _PWRTE_ON & _WDT_ON & _HS_OSC
DEFINE OSC 20
TRISB = 0
PR2 = 122
CCPR1L = 64
T2CON = %00000100
CCP1CON = %00001100
here: goto here
-
Steve,
Still no joy. Your config line won't compile for me, I am using I think PBP 2.42. I tried using my code with the here: goto here, and still no success.
Thanks for the help. I am getting frustrated with this. All I want is a lil PWM...
Jonathan
-
On this device CCP1 is multiplexed with RB0 & RB3. To switch CCP1 you
use CCPMX in CONFIG1.
With CCPMX left un-programmed, CCP1 defaults to RB0.
Try this.
Code:
@ DEVICE HS_OSC,CCPMX_ON,MCLR_ON,LVP_OFF,WDT_OFF,PROTECT_OFF
' CCPMX_ON = PWM ON RB3, CCPMX_OFF = PWM ON RB0
DEFINE OSC 20
TRISB = 0
CMCON = 0
ADCON0 = 0
ANSEL = 0
PR2 = 122
CCPR1L = 64
T2CON = %00000100
CCP1CON = %00001100
Here:
GOTO Here
-
Funny ...
16F88 is not supported by PBP 2.42 ....
LOL
Verify your release and upgrade ( 2.46 now ...)
Alain
-
Bruce,
As always, you da man! Working great now. I beleive that the ADCON0 was the main source of the problem, as I was checking RB0 as well as RB3.
What fun! I can get to work now instead of pounding my head on the keyboard.
Ace, I haven't checked, but I must have 2.43 or something, because I can indeed program the 16F88. I am going to get the upgrades from Bruce soon.
Thanks all!!
Jonathan
-
You had RB0 set as an input. That's why you didn't see your PWM
signal output on RB0.
I think you have at least V2.45. That's when support for the 16F88
was added. I do recommend upgrading to V2.46. The new version
adds a ton of new devices including the new 18F full-speed USB PICs.