Computing.Net > Forums > Programming > 16F84 interface to keyboard port

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

16F84 interface to keyboard port

Reply to Message Icon

Name: ejp
Date: September 30, 2003 at 07:31:59 Pacific
OS: DOS
CPU/Ram: 256
Comment:

i've looked all over, and it's been done before. there's so many similar projects that have done the same thing, but i don't know which one is the one for me.

i'm doing a project, which uses the keyboard. however, i want to get rid of the keyboard altogether. i want to use the PIC16F84 instead. i don't need all the keys. and the 16F84 must interface to the PS/2 port.

i have a compiler for ASM and BASIC. no C++ though. which project online should i use?



Sponsored Link
Ads by Google

Response Number 1
Name: Infinite Recursion
Date: September 30, 2003 at 12:20:26 Pacific
Reply:

I don't know of any one project to use... there are several out there and all of them have their pros and cons.

However, if I were you, I would put away BASIC and go get a free C++ compiler. They are scattered throughout the net, the one I currently use is Dev-C++ located at
http://www.bloodshed.net

IR


0

Response Number 2
Name: borelli35
Date: September 30, 2003 at 23:26:51 Pacific
Reply:

================================================================
Ok...if I understand correctly then you want to know how to program the hardware in question through interrupt controls so I will use the mouse as an example of how to make these calls as embedded asm code within Turbo BASIC (since you didn't specify what BASIC compiler you will be using). Although the PIC can be programmatically controlled, there is no real need to take this approach for what you have described so the asm code for programming for mouse control follows:


REM
REM all function calls are made using
REM interrupt 33h
REM
REM let's first intitialize the mouse
asm
mov ax,00h ;move function num. 0 into ax
int 33h ;call interrupt 33h
end

REM the mouse show function increments the mouse
REM show counter by one each time it is
REM called. The mouse hide function
REM decrements the mouse show counter by 1
REM each time it is called. The show mouse
REM counter must be greater than 0 in order
REM for the mouse to be visible. The mouse
REM show function must be called after init-
REM ializing the mouse in order for it to be
REM visible. It is therefore advisable that
REM you externally track the value of this
REM counter in a variable in order to know
REM whether or not the mouse is visible or
REM not.
REM
REM let's display the mouse cursor
dim show_count as integer = 0
asm
mov ax,01h ;move function 1 into ax reg.
int 33h ;and call interrupt 33h
end
show_count=show_count + 1

REM let's hide the mouse cursor (or at least
REM decrement the show cursor counter
asm
mov ax,02h ;move function 2 into ax reg.
int 33h ;and call interrupt 33h
end
show_count=show_count - 1

REM let's get the mouses x,y position
dim x,y as integer
asm
mov ax,03h ;move funtion 3 into ax reg.
int 33h ;and call interrupt 33h
mov x,cx ;the x position is in cx reg.
mov y,dx ;the y position is in dx reg.
end

REM call function 03h to get the mouse
REM button status as well
dim buttons as integer
asm
mov ax,03h ;move function 3 into ax reg.
int 33h ;and call interrupt 33h
mov buttons,bx ;the buttons bitmask value
end

There are other functions but this is primarily what you will need. The buttons variable value is as follows:

buttons=1 then left mouse button pressed
buttons=2 then right mouse button pressed
buttons=4 then center mouse button pressed
buttons=6 then center/right mouse buttons pressed
buttons=5 then center/left mouse buttons pressed
buttons=7 then center/left/right mouse buttons pressed
buttons=3 then right/left mouse buttons pressed

I hope this isn't too confusing. It shows how to program for the mouse. If you need info on DOS programming for the keyboard or some other interrupt information just post back and I'll do my best to help.

borelli35


0

Response Number 3
Name: ejp
Date: October 3, 2003 at 07:22:56 Pacific
Reply:

well, i need coding soley for the keyboard. of course, that's been done before. the only thing is that not all of the projects come complete with a schematic.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: 16F84 interface to keyboard port

Pascal - Keyboard port number ???? www.computing.net/answers/programming/pascal-keyboard-port-number-/1556.html

'Printing' to a port www.computing.net/answers/programming/printing-to-a-port/5291.html

C interface to C++ www.computing.net/answers/programming/c-interface-to-c/1714.html