Information

2003 Microchip Technology Inc. DS80072D-page 3
PIC16C712/716
EXAMPLE 2:
(Assumes that the T2CON and CCP1CON values may change during program execution. One SRAM location is used
for temporary storage of T2CON or CCP2CON.)
Code Example 2A:
;***********************************************************************
; Call these routines to turn the PWM off or on and ensure a Zero output on RB3
; when PWM is off.
;
; PWMreset - Saves T2CON value in RAM location. IT IS THE RESPONSIBILITY OF THE USER TO SUPPLY
; RAM MEMORY SPACE TO SAVE THE T2CON VALUE.
; Clears T2CON register Disabling Timer2 and clearing Timer2 Prescaler.
; The TMR2 register is then filled with the CCPR1H value. This causes a Reset
; or Zero value on RB3.
;
; PWMrestart - Enable Timer2
Assembly Code To Stop PWM Once Started:
T2CONSAV equ 0x?? ; USER RESPONSIBLE FOR SUPPLYING RAM MEMORY SPACE
; TO SAVE T2CON VALUE.
PWMreset
bcf STATUS,RP0 ; Select Bank 0
movf T2CON,W ; Move T2CON Value to ‘w’ register
movwf T2CONSAV ; Save T2CON register value
clrf T2CON ; Clear T2CON, Timer2-Disable & Pre/Post Scalers=1
movf CCPR1H,W ; Load CCPR1H value in Write register
movwf TMR2 ; Move CCPR1H value into TMR2 to cause Reset of RB3 pin
return
Assembly Code To Start PWM Once Stopped:
PWMrestart
bcf STATUS,RP0 ; Select Bank 0
movf T2CONSAV,W ; Move T2CONSAV Value to ‘w’ register
movwf T2CON ; Restore T2CON register value
return