
Originally Posted by
iugmoh
I read alot about barcode reader ps/2 protocol and know how it works and how i can interface with PIC16f877a , but i don't where is the problem I don't know how to display this ID number on an LCD for example
please anyone have an idea how to read barcode reader and display on LCD ?
A bit contradictory, dontcha think?
Anywhos...
Usually, I put my On Interrupt near the beginning of a program, and skip over it into my main program. Some say it's good practice, others say they don't care, and still others say it straightens out execution sometimes. I don't know, I just know it works for me.
So, assuming you really have a good handle on your hardware and how the barcode scanner actually works, then this little bit of a rewrite should work for you.
(yes it's all crammed together, that's just the way I roll, you can reformat it all you want)
Code:
<-----LCD & Other DEFINES.....
<-----
clr con 1 : line1 con 128 : line2 con 192 : line3 con 148 : line4 con 212
ins con 254 : scl var portc.3 : sda var portc.4 : clock_barcode var portb.0
data_barcode var portb.1 : input clock_barcode : input data_barcode
output portd.1 : but1 var portb.2 : input but1 : portd.1 = 0 : option_reg = 5
pause 2000 : intcon = $90 : addr var byte : char var byte
ee_byteout var byte : ee_bytein var byte : id var bit[250]
countstep var byte : counter var byte : counter = 0 : trisd = 0 : ee_byteout = 0
On Interrupt Goto reg_id
goto mainloop
DISABLE ' Disable interrupts in handler
reg_id:
intcon.1 = 0
if clock_barcode=0 then ; test falling edge
id[counter]=data_barcode
endif
counter=counter+1 : portd.1=data_barcode
RESUME ' Return to main program
ENABLE ' Enable interrupts after handler[/QUOTE]
mainloop: lcdout Ins,clr,Line1,"Please Ins. ID card"
Main:
if but1=0 then
lcdout ins,clr,line1,#counter,ins,line2 : pause 3000
for countstep=0 to counter : lcdout #id[countstep] : pause 2000 : next
counter=0
endif
goto main ' Remain in loop
end
And it looks to me as if the whole code isn't here...
Bookmarks