iskendercilce
Üye
- Katılım
- 8 Tem 2007
- Mesajlar
- 151
- Puanları
- 1
- Yaş
- 40
list p=16F877A
include "p16F877A.inc"
__config H'3F3A'
;genel degiskenler
tmp equ 0x20 ;1 byte
delay_ms_tmp equ 0x21 ;2 byte
pwm_set_degeri equ 0x23
org 0
clrf PCLATH
goto ana_program
pwm_baslat
movlw D'63'
banksel PR2
movwf PR2
movlw 0x0c
banksel CCP1CON
movwf CCP1CON
clrf CCPR1L
banksel TRISC
bcf TRISC,2
movlw D'4'
banksel T2CON
movwf T2CON
return
pwm_set
banksel pwm_set_degeri
movf pwm_set_degeri,w
andlw d'3'
movwf tmp
swapf tmp,w
andlw 0xf0
banksel CCP1CON
movwf CCP1CON
iorlw 0x0c
movwf CCP1CON
movf pwm_set_degeri,w
movwf tmp
rrf tmp,f
rrf tmp,w
andlw 0x3f
movwf CCPR1L
return
pwm_sonlandir
banksel T2CON
clrf T2CON
clrf CCP1CON
return
ilk_islemler
banksel TRISA
movlw d'6'
movwf ADCON1
movlw 0xff
movwf TRISA
return
delay_ms
delay_j1
movlw .185
movwf delay_ms_tmp+1
nop
delay_j2
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz delay_ms_tmp+1,f
goto delay_j2
nop
decfsz delay_ms_tmp,f
nop
return
ana_program
call ilk_islemler
banksel pwm_set_degeri
movwf pwm_set_degeri
ana_j1
banksel PORTA
btfsc PORTA,4
goto ana_j1
call pwm_baslat
call pwm_set
ana_j2
banksel PORTA
btfsc PORTA,3
goto ana_j3
call pwm_sonlandir
goto ana_j1
ana_j3
banksel PORTA
btfsc PORTA,1
goto ana_j4
movlw 0xff
subwf pwm_set_degeri
btfss STATUS,C
incf pwm_set_degeri,f
movlw d'10'
movwf delay_ms_tmp
call delay_ms
call pwm_set
ana_j4
banksel PORTA
btfsc PORTA,2
goto ana_j2
movf pwm_set_degeri,w
sublw d'0'
btfss STATUS,C
decf pwm_set_degeri,f
movlw d'10'
movwf delay_ms_tmp
call delay_ms
call pwm_set
goto ana_j2
end
yukardaki kodda bi hata var ornegi bi kitaptan aldim min ve max noktalarini kaciriyor
include "p16F877A.inc"
__config H'3F3A'
;genel degiskenler
tmp equ 0x20 ;1 byte
delay_ms_tmp equ 0x21 ;2 byte
pwm_set_degeri equ 0x23
org 0
clrf PCLATH
goto ana_program
pwm_baslat
movlw D'63'
banksel PR2
movwf PR2
movlw 0x0c
banksel CCP1CON
movwf CCP1CON
clrf CCPR1L
banksel TRISC
bcf TRISC,2
movlw D'4'
banksel T2CON
movwf T2CON
return
pwm_set
banksel pwm_set_degeri
movf pwm_set_degeri,w
andlw d'3'
movwf tmp
swapf tmp,w
andlw 0xf0
banksel CCP1CON
movwf CCP1CON
iorlw 0x0c
movwf CCP1CON
movf pwm_set_degeri,w
movwf tmp
rrf tmp,f
rrf tmp,w
andlw 0x3f
movwf CCPR1L
return
pwm_sonlandir
banksel T2CON
clrf T2CON
clrf CCP1CON
return
ilk_islemler
banksel TRISA
movlw d'6'
movwf ADCON1
movlw 0xff
movwf TRISA
return
delay_ms
delay_j1
movlw .185
movwf delay_ms_tmp+1
nop
delay_j2
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
decfsz delay_ms_tmp+1,f
goto delay_j2
nop
decfsz delay_ms_tmp,f
nop
return
ana_program
call ilk_islemler
banksel pwm_set_degeri
movwf pwm_set_degeri
ana_j1
banksel PORTA
btfsc PORTA,4
goto ana_j1
call pwm_baslat
call pwm_set
ana_j2
banksel PORTA
btfsc PORTA,3
goto ana_j3
call pwm_sonlandir
goto ana_j1
ana_j3
banksel PORTA
btfsc PORTA,1
goto ana_j4
movlw 0xff
subwf pwm_set_degeri
btfss STATUS,C
incf pwm_set_degeri,f
movlw d'10'
movwf delay_ms_tmp
call delay_ms
call pwm_set
ana_j4
banksel PORTA
btfsc PORTA,2
goto ana_j2
movf pwm_set_degeri,w
sublw d'0'
btfss STATUS,C
decf pwm_set_degeri,f
movlw d'10'
movwf delay_ms_tmp
call delay_ms
call pwm_set
goto ana_j2
end
yukardaki kodda bi hata var ornegi bi kitaptan aldim min ve max noktalarini kaciriyor