Hi again,
I’m trying to move what I learned last week to a larger PIC (PIC16F819) which I have a lot of leftovers and I’m trying to make use of. I’m also trying to increase my output frequency by using a 16MHz oscillator.
Based on what the data sheet shows I should have about the same setup as I had with PIC12F683 except that I could select between RB2 and RB3 as my output.
With the above code I get good output on RB1 (led out which proves that the system is running) but I do not get any output on RB2 or RB3. I was hoping that it will go by default on one of them.
Code:
@ device pic16F819, wdt_off, hs_osc, pwrt_on, mclr_off, lvp_off, protect_on
DEFINE OSC 16 ' We're running at 16 Mhz
ADCON1=%01001110 ' Digital only for all pins
led var PORTB.1
i var byte
CCP1CON = %00001100 ' Normal PWM
PR2 = 3
CCPR1L =0
CCP1CON.5 = 1
CCP1CON.4 =1
For i = 0 to 9
Toggle LED
Pause 500
NEXT
Main:
high led
CCP1CON = %00001100 ' Normal PWM mode
T2CON.2 = 1 ' Timebase ON
PAUSE 15
low led
T2CON.2 = 0 ' Timebase OFF
CCP1CON = %00000000 ' Disable PWM to regain control of PortA.2
PAUSE 5
Goto Main
The data sheet states:
The CCP module’s input/output pin (CCP1) can be
configured as RB2 or RB3. This selection is set in bit 12
(CCPMX) of the Configuration Word register.
I have no idea how to change this setting and if this is the reason why I get no output.
Is there anything that I should do differently?
Thank you in advance for any input.
Nick
Bookmarks