; ****************************************** ; www.endtas.com/robot hobby robotics site ; ****************************************** ; Robotarm asm source ; ****************************************** ; Robotkol asm kodu ; ****************************************** ; Copyright özkal özsoy 9 / 2003 ; ****************************************** ; if you use my code or circuit ; give me credit please ; ****************************************** ; Eğitim amacı ile ve endtas.com ; robotik sitesi kaynak gösterilerek ; kullanılabilir. ; ****************************************** ; Compile with RC oscillator option selected ; with watchdog off. ; ****************************************** ; RC osilatör ve watchdog kapalı seçenekleri ; ile derleyiniz. ; ****************************************** list p=16f84a #include "P16F84a.INC" ; Include header file __config _CP_OFF & _PWRTE_OFF & _WDT_OFF & _RC_OSC ; bellekler sayac1 EQU h'000c' sayac2 EQU h'000d' timer equ h'000e' timsay equ h'000f' statemp equ h'0010' wtemp equ h'0011' pobaz equ h'0012' pobir equ h'0013' poiki equ h'0014' pogrip equ h'0015' depo1 equ h'0016' depo2 equ h'0017' flag1 equ h'0018' kayadr equ h'0019' org 0 start clrf INTCON goto main nop nop intvec movwf wtemp ; save off current W register contents movf STATUS,w ; move status register into W register movwf statemp ; save off contents of STATUS register btfss INTCON,T0IF ; Timer0 interrupt? goto pop bcf INTCON,T0IF ; Clear the Timer0 interrupt flag banksel PORTB incf timsay btfsc STATUS,Z incf timer ; ***************************** pwm start movfw timsay subwf pobaz,0 btfss STATUS,C goto cik1 cik2 bsf PORTA,0 goto pobire cik1 bcf PORTA,0 ;------------------------ pobire movfw timsay subwf pobir,0 btfss STATUS,C goto cik12 cik22 bsf PORTA,1 goto poikiye cik12 bcf PORTA,1 ;------------------------ poikiye movfw timsay subwf poiki,0 btfss STATUS,C goto cik13 cik23 bsf PORTA,2 goto pogripe cik13 bcf PORTA,2 ;------------------------ pogripe movfw timsay subwf pogrip,0 btfss STATUS,C goto cik14 cik24 bsf PORTA,3 goto pop cik14 bcf PORTA,3 ; ***************************** pwm end pop movf statemp,w ; retrieve copy of STATUS register movwf STATUS ; restore pre-isr STATUS register contents swapf wtemp,f swapf wtemp,w ; restore pre-isr W register contents retfie main banksel TRISB movlw b'11111111' ; PORTB giriş, movwf TRISB movlw b'00010000' ; PORTA koşullamaları. 4. pin giriş. digerleri pwm çıkışı. movwf TRISA call init banksel PORTB clrf PORTB bcf OPTION_REG,7 ; Enable portb pullups webbas movlw d'02' movwf pobir movlw d'02' movwf poiki movlw d'02' movwf pobaz movlw d'02' movwf pogrip call uzbekle call uzbekle call uzbekle call uzbekle movlw d'06' movwf pobir movlw d'06' movwf poiki movlw d'06' movwf pobaz movlw d'06' movwf pogrip call uzbekle call uzbekle call uzbekle call uzbekle goto webbas ;***************************************** uzbekle call bekle call bekle call bekle call bekle call bekle return ;***************************************** bekle bsf PORTA,4 clrf sayac1 loop1 clrf sayac2 loop incf sayac2 nop nop nop btfss sayac2,7 goto loop nop nop nop incf sayac1 btfss sayac1,7 goto loop1 bcf PORTA,4 return ;**************************** init movlw 0x8a ;0x8F ; Set the timer prescaler. banksel OPTION_REG movwf OPTION_REG banksel TMR0 movlw 0x00 movwf TMR0 bsf INTCON,T0IE ; Enable the timer interrupt. bsf INTCON,GIE ; Enable global interrupts. return end