Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/14/02 18:13
Read: times


 
#27249 - help me find source code problem
Hi, there
A few days ago I posted a problem about card reader swipe.. The problem hasn't been solved for a week. I will post my source code here and to see if somebody can help me find a problem...



.org 0 ; powerup
ajmp start

.org 0003h ; external Interrupt 0
ajmp keyboard ISR ;keyboard interrupt service programm
;exactly same as philips application


start:

;initializtion


;here I call keypressed subroutine to check
;if there is a key pressed...

MOV RX_POSITION, #RX_BUFFER ; RX_BUFFER IS BUFFER TO SAVE KEY SCAN CODE
main:

lcall keypressed
sjmp main

keypressed:

MOV A, NBYTES ;this variable is set to 1 when key was pressed
JZ MYLOOP ;if not, jump to myloop and return to main

MOV IE, #00 ;disable all the interrupts
MOV A, KEYBUFF ;keybuff is used to save key..
MOV NBYTES, #00H ;after key was saved to buffer, clear NBYTES
MOV R1,RX_POSITION ;save the byte in rx buffer
MOV @R1,A
INC R1
MOV RX_POSITION,R1
MOV IE, #91H ;enable interrupts

MOV TH0,#11 ;50ms timers..this is calculated using equation on 8052.com
MOV TL0,#220
MOV TMOD,#01
SETB TR0
JNB TF0,$

;this part I supposed to do is get key scan code and save,
;waiting 50 ms...
;during the waiting period there is a key pressed, jump to ISR..
;otherwise it will send out char to display


MOV R1, RX_POSITION ;read current RX_POSITION value
MOV R0, #RX_BUFFER ;starting address of buffer
Loop1:
MOV DPTR, #UART ;send out through uart
MOV A, @R0
MOVX @DPTR, A
INC R0
DEC R1
CJNE R1, #RX_BUFFER, Loop1 ;


MOV RX_POSITION, #RX_BUFFER ;reset rx_position

MYLOOP:

RET



Any problem of my code? when I pressed a single key, I can get correct answer..if I swipe the card, I cann't get correct scan codes. The hardware is OK. I have connected this keyboard with PC, I swipe the card and get corrected digits using notepad and wordpad..

I am confusing now is during the timer0 count period, if the key is pressed, the program will jump to keyboard ISR,after ISR, the program will start from where? the beginning of keypressed subroutine
or going on counting timer?


Regards

Frank









List of 11 messages in thread
TopicAuthorDate
help me find source code problem            01/01/70 00:00      
RE: help me find source code problem            01/01/70 00:00      
RE: help me find source code problem            01/01/70 00:00      
RE: help me find source code problem            01/01/70 00:00      
RE: help me find source code problem            01/01/70 00:00      
RE: help me find source code problem            01/01/70 00:00      
Final result            01/01/70 00:00      
RE: Final result            01/01/70 00:00      
RE: Final result            01/01/70 00:00      
RE: help me find source code problem            01/01/70 00:00      
RE: help me find source code problem            01/01/70 00:00      

Back to Subject List