need help to check if this A to D conversion and PWM initialization is right..
i am doing a 8 speed motor controller using PWM(pic 16f876). but when i turn my potentiometer it doesn't seem to increase or decrease the speed.I am using a 10MHz oscillator. If the program is correct how do i go about detecting the speed change from the potentiometer.i am using a speed detection motor to feedback the speed.Pls help!
;**************** Program Start ***********************
org 0
goto init
;**************** Initial Process *********************
init
;*** Port initialization
bsf status,rp0
movlw b'00000001'
movwf trisa
clrf trisb
clrf trisc
bcf status,rp0
;*** A/D converter initialization
movlw b'10000001'
movwf adcon0
bsf status,rp0
movlw b'00001110'
movwf adcon1
bcf status,rp0
;*** PWM initialization
clrf tmr2
movlw b'11111111'
movwf ccpr1l
bsf status,rp0
movlw d'255'
movwf pr2
bcf status,rp0
movlw b'00000110'
movwf t2con
movlw b'00001100'
movwf ccp1con
;*** Compare mode initialization
clrf tmr1h
clrf tmr1l
movlw h'61'
movwf ccpr2h
movlw h'A8'
movwf ccpr2l
movlw b'00000001'
movwf t1con
movlw b'00001011'
movwf ccp2con
;*** Interruption control
bsf status,rp0
movlw b'00000001'
movwf pie2
bcf status,rp0
movlw b'11000000'
movwf intcon
i am doing a 8 speed motor controller using PWM(pic 16f876). but when i turn my potentiometer it doesn't seem to increase or decrease the speed.I am using a 10MHz oscillator. If the program is correct how do i go about detecting the speed change from the potentiometer.i am using a speed detection motor to feedback the speed.Pls help!
;**************** Program Start ***********************
org 0
goto init
;**************** Initial Process *********************
init
;*** Port initialization
bsf status,rp0
movlw b'00000001'
movwf trisa
clrf trisb
clrf trisc
bcf status,rp0
;*** A/D converter initialization
movlw b'10000001'
movwf adcon0
bsf status,rp0
movlw b'00001110'
movwf adcon1
bcf status,rp0
;*** PWM initialization
clrf tmr2
movlw b'11111111'
movwf ccpr1l
bsf status,rp0
movlw d'255'
movwf pr2
bcf status,rp0
movlw b'00000110'
movwf t2con
movlw b'00001100'
movwf ccp1con
;*** Compare mode initialization
clrf tmr1h
clrf tmr1l
movlw h'61'
movwf ccpr2h
movlw h'A8'
movwf ccpr2l
movlw b'00000001'
movwf t1con
movlw b'00001011'
movwf ccp2con
;*** Interruption control
bsf status,rp0
movlw b'00000001'
movwf pie2
bcf status,rp0
movlw b'11000000'
movwf intcon