;learning to do pwm with tmro 12f675
list P=12f675
#include <p12f675.inc>
__config _INTRC_OSC_NOCLKOUT & _BODEN_OFF & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _CP_OFF
ERRORLEVEL -302
cblock 20h
pwmcounter, channel1, channel2
endc
ORG 0000h
goto setup
ORG 0004h
movlw 0x03 ;interrupt turns on motors then
movwf GPIO ;call pwm keeps checking to see it's
BCF INTCON,2 ;time to shut them off
RETFIE ;reset interrupt
setup
bsf STATUS,RP0 ;bank 1
movlw 0x3c
movwf ANSEL
movlw 0x3c
movwf TRISIO ;set I/O
movlw 0xd0
movwf OPTION_REG ;set tmr0
bcf STATUS,RP0
movlw 0x07 ;turn off comparitors
movwf CMCON
movlw 0xa0
movwf INTCON ;set interrupt
start
movlw 0x09
movwf ADCON0
call pwm
call pwm
call pwm
call pwm
call pwm
call pwm
call pwm
bsf ADCON0,1
call pwm
waiting
btfsc ADCON0,1
goto waiting
call pwm
call pwm
call pwm
movf ADRESH,0
movwf channel1
movlw 0x0d ;change to read channel 2 potentiometer
movwf ADCON0
call pwm ;time for adc recharge
call pwm
call pwm
call pwm
call pwm
call pwm
call pwm
bsf ADCON0,1
waiting2
btfsc ADCON0,1 ;waiting for adc
goto waiting2
call pwm
call pwm
call pwm
movf ADRESH,0
movwf channel2
goto start
pwm
movf channel1,0
addwf TMR0,0
btfss STATUS,C ;test flag if set then turn off GPIO,0
bcf GPIO,0
movf channel2,0
addwf TMR0,0
btfss STATUS,C
bcf GPIO,1
return
end