zhaniko93
New Member
I have Pic16f84A Code:
And Proteus Project, which I attached and the problem is that when I connect 5V to RB6 (accelerate), motor accelerates constantly but when I connect 5V to rb5(Decelerate), motor stops running imediatelly and I can't understand why.
Code:
list p=16F84A ; list directive to define processor
#include <p16F84A.inc> ; processor specific variable definitions
errorlevel -302, -207
__config _XT_OSC & _WDT_OFF & _CP_OFF
;============
; Declarations:
acc_level equ 0x0c
Test equ 0x0d
#define main_eng PORTA, 1
#define accel PORTB, 6
#define slow_down PORTB, 5
clrf acc_level
clrf PORTA ; resets Port A
clrf PORTB
bsf STATUS,RP0 ; BANK1
movlw b'0000' ; RA0: LED, RA1-3: not connected
movwf TRISA
movlw b'01011011'
movwf TRISB
movlw 0x0
movwf INTCON
movlw b'11010100'
movwf OPTION_REG
bcf STATUS, RP0
;============
Main
movfw acc_level
movfw Test
btfsc accel
call gazi
btfsc slow_down
call tormuzi
; Start Engine
call Going
call Going
call Going
call Going
call Going
goto Main
Going clrf TMR0
bsf main_eng
Mda movfw acc_level
subwf TMR0, 0
btfss STATUS, Z
goto Mda
call W8ing
retlw 0
W8ing movfw TMR0
sublw 0xFF
bcf main_eng
movwf Test
decfsz Test,F
goto W8ing
retlw 0
gazi movfw acc_level
sublw 0xFE
btfss STATUS, Z
incf acc_level,F
retlw 0
tormuzi movfw acc_level
sublw 0x00
btfss STATUS, Z
decf acc_level,F
retlw 0
end