PWM for Hobby Motor using P16F685 no CCP output

Started by Bob Lynch August 27, 2008
Can anyone see a problem with this code, just looking for a duty
cycle. Thanks
;*********************************************************************
*
;
; Filename: PWM071308.asm
; Date: 6/15/08
; File Version: 1.00
;
; Author: Bob Lynch
;*********************************************************************
*
;
; Files required:
; p16F685.inc
;*********************************************************************
*

#include ; processor specific variable
definitions

__CONFIG _CP_OFF & _CPD_OFF & _MCLRE_OFF & _WDT_OFF &
_PWRTE_ON & _INTRC_OSC_NOCLKOUT & _FCMEN_OFF & _IESO_OFF

org 0x0000
Start:
banksel OSCCON ; Bank 1
movlw B'01110111' ; Internal oscillator frequency = 8 MHz
movwf OSCCON

;banksel PORTC ; Bank 0
;clrf PORTC ; Init PortC

banksel CM1CON0 ; Bank 2
movlw b'00000111'
movwf CM1CON0 ; Turn comparators off

banksel ANSEL ; Bank 2
clrf ANSEL ; Turn off ADC
clrf ANSELH

;1. Disable the PWM Pin.
banksel TRISC ; Bank 1
movlw 0xFF
movwf TRISC ; Disable the P1B PWM Pin

;2. Set the PWM period by loading the PR2 register.
banksel PR2 ; Bank 1
movlw 0x3F ; Load the count of 31.2kHz 8-bit rez in
PR2
movwf PR2 ; PWM period is set by PR2 register of
timer2.

;3. Configure CCP Module.
banksel CCP1CON ; Bank 0
movlw b'00001100'
movwf CCP1CON ; Set CCP1M2 to 1100 for PWM Mode

;4. Set Duty Cycle.
banksel CCPR1L ; Bank 0
movlw 0X00
movwf CCPR1L ; Duty Cycle is 25% of PWM Period

;5. Set Timer2.
bcf PIR1,TMR2IF ;
banksel T2CON ; Bank 0
movlw b'00000100'
movwf T2CON ; Set prescale & Start Timer2

;6. Enable PWM Output.
PWM_Period_Match
btfss PIR1,TMR2IF
goto PWM_Period_Match

banksel TRISC ; Bank 1
clrf TRISC ; Enable the P1B PWM Pin

end