zhaniko93
New Member
Take a look at my program:
The programs looks difficult but the problem, I think, doesn't need exploring the code.
when I simulate this in Proteus, everything is ok but if I click any of w, a, d, s or n buttons and just keep my finger on the button, everything stucks at fourth send of character. if I remove the <<<<THIS (call Dacda), even if I click and keep finger on button, everything runs ok... what's wrong? I have attached proteus file, this code is Pulti.asm and you can remove second PIC from proteus file (which requires dzrava.hex) I have tried many things but solving the problem already seems impossible to me becouse of my small experience. can any1 help me?
Code:
; W = 196 (32)
; S = 160 (64)
; A = 128 (96)
; D = 96 (128)
; N = 64 (160)
#define K_win PORTA, 4
#define K_ukan PORTA, 3
#define K_marjvniv PORTA, 2
#define K_marcxniv PORTA, 1
#define K_turbo PORTA, 0
LIST P=16F628A, R=DEC ; Use the PIC16F628 and decimal system
#include "P16F628A.INC" ; Include header file
__config _INTRC_OSC_NOCLKOUT & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON & _MCLRE_OFF
errorlevel -302
goto Start
org 0x4
movwf WRKNG
call ISR
movfw WRKNG
retfie
cblock 0x20
T1
T2
T3
T4
T5
WRKNG
TURBOO
endc
Start movlw 7
movwf CMCON
movlw b'11000000'
movwf INTCON
clrf PORTA
clrf PORTB
banksel TRISA
movlw b'00000110' ; RB2(TX)=1 others are 0
movwf TRISB
movlw b'00011111'
movwf TRISA
;INTERRUPT
movlw b'00100000'
movwf PIE1
; Boot Baud Rate = 9600, No Parity, 1 Stop Bit
;
movlw 0x19 ; 0x19=9600 bps (0x0C=19200 bps)
movwf SPBRG
movlw b'00100100' ; brgh = high (2)
movwf TXSTA ; enable Async Transmission, set brgh
BANKSEL RCSTA
movlw b'10010000' ; enable Async Reception
movwf RCSTA
call message
loop movlw 3
btfss K_win
addwf PCL, f
call Dacda_
movlw 32
call Action
movlw 3
btfss K_ukan
addwf PCL, f
call Dacda_
movlw 64
call Action
movlw 3
btfss K_marjvniv
addwf PCL, f
movlw 96
call Action
call Dacda__
movlw 3
btfss K_marcxniv
addwf PCL, f
movlw 128
call Action
call Dacda__
movlw 3
btfss K_turbo
addwf PCL, f
movlw 160
call Action
call Dacda__
goto loop
; -------------------------------------------------------------
; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING
; -------------------------------------------------------------
;
send movwf TXREG ; send data in W
banksel TXSTA
btfss TXSTA,TRMT ; (1) transmission is complete if hi
goto $-1
banksel PORTA
return
ISR movf RCREG,W
call send
movwf T1
sublw A'w'
movlw 2
btfss STATUS, Z
addwf PCL, f
movlw 32
call Action
movfw T1
sublw A's'
movlw 2
btfss STATUS, Z
addwf PCL, f
movlw 64
call Action
movfw T1
sublw A'a'
movlw 2
btfss STATUS, Z
addwf PCL, f
movlw 96
call Action
movfw T1
sublw A'd'
movlw 2
btfss STATUS, Z
addwf PCL, f
movlw 128
call Action
movfw T1
sublw A'n'
movlw 2
btfss STATUS, Z
addwf PCL, f
movlw 160
call Action
return
Action iorwf PORTB, f
call Dacda
call Dacda
call Dacda
call Dacda ;<<<<<<<--------------------------------------------- THIS!!!!!!!!!!
movlw b'00011111'
andwf PORTB, f
return
Del1 movlw 30
movwf T2
decfsz T2, f
goto $-1
return
message movlw A'J'
call send
movlw A'a'
call send
movlw A'K'
call send
movlw A'o'
call send
movlw A' '
call send
movlw A'V'
call send
movlw A'0'
call send
movlw A'.'
call send
movlw A'1'
call send
movlw 0x0D
call send
return
Dacda_ call Dacda
call Dacda
call Dacda
call Dacda
return
Dacda__ movlw 50
movwf TURBOO
XAX decfsz TURBOO, f
call Dacda_
decfsz TURBOO, f
goto XAX
return
Dacda movlw 200
movwf T3
decfsz T3, f
call Del1
decfsz T3, f
goto $-3
return
END
The programs looks difficult but the problem, I think, doesn't need exploring the code.
when I simulate this in Proteus, everything is ok but if I click any of w, a, d, s or n buttons and just keep my finger on the button, everything stucks at fourth send of character. if I remove the <<<<THIS (call Dacda), even if I click and keep finger on button, everything runs ok... what's wrong? I have attached proteus file, this code is Pulti.asm and you can remove second PIC from proteus file (which requires dzrava.hex) I have tried many things but solving the problem already seems impossible to me becouse of my small experience. can any1 help me?