>> From: Mark Jurras <
.....JURRAMKILLspam
@spam@torrington.com>
>>
>> I need to output a 50% Duty Cycle Fixed Frequency without tying up the
>> processor. and I figured that the PWM might do the trick. Most of the app
>> notes on the CD seem to relate to the 17C parts or the PWM theory. The Data
>> Sheet doesn't give much detail on exactly what needs to be set up.
>>
>> Since I need to just output a fixed frequency do I need to setup the
>> interrupts?
>>
>> - -Mark
>>
>
>Assuming you are using a PIC16C7X (i.e. one with a PWM module), setting
>up for PWM output is documented quite well in the Microchip Datasheet
>for the 16C7X. Here is some code for PWM1:
>
>setup bsf status,rp0
> movlw PWM_PERIOD
> movwf pr2 ; Set up period register
> bcf status,rp0
>; Optionally, set up TMR2 prescaler (not shown here)
> movlw 1<<tmr2on
> movwf t2con ; Turn on timer 2
> movlw 0Ch
> movwf ccp1con ; Set PWM mode
> movlw PWM_PERIOD/2 ; Constant for 50% duty cycle
> movwf ccpr1l ; Set duty cycle
>; Optionally, set 'fine control' bits for up to 10-bit resolution (not shown).
> ...
>turnoff clrf t2con ; Turn off timer 2
> clrf ccp1con ; Turn of CCP 1.
>
>No interrupt handling is required.
>
>Regards,
>SJH
>Canberra, Australia
>
>