|
|
View previous topic :: View next topic |
Author |
Message |
ecah
Joined: 06 Mar 2009 Posts: 2
|
HELP NEEDED..cannot send data using ps2 keyboard |
Posted: Thu Mar 19, 2009 2:58 am |
|
|
everytime i connect the ps2 connector to the pc, pc will make a beep sound and there is no data being send from pic
here is my code. i just want to send character 'A' using ps/2
A=0001 1100
porta0 = clock
portb0 = data
#include <16f877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NOPUT
#use delay(clock=4000000)
#byte porta=5
#byte portb=6
void main()
{
set_tris_a(0);
set_tris_b(0);
porta=0x00;
portb=0x00;
delay_ms(100);
while (1)
{
porta=0x01;
delay_us(10);
portb=0x00; //send startbit
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x00; //send 0
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x00; //send 0
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x01; //send 1
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x01; //send 1
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x01; //send 1
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x00; //send 0
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x00; //send 0
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x00; //send 0
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x01; //send parity bit
delay_us(10);
porta=0x00;
delay_us(50);
porta=0x01;
delay_us(10);
portb=0x01; //send stopbit
delay_us(10);
porta=0x00;
delay_us(50);
}
} |
|
|
Ttelmah Guest
|
|
Posted: Thu Mar 19, 2009 3:48 am |
|
|
How about searching here. There have been PS/2 drivers posted in the past....
Your basic understanding of PS/2 is flawed. When you are not driving the lines, these _must_ be set as 'float'. You need to verify that both lines are high, before starting. To send a '1' (high), you set the line to 'float'. You only drive the line, when you want to send a '0'. If the clock line goes low during the period when it is floating, then you must stop sending data (basically the PC wants to take control of the line).
Then, you don't send 'characters', using PS/2, but keyboard scan codes. To send 'A', you need to send the scan code for 'key A down', then the code 'F0' (release), followed by the same scan code. The scan code for 'A', on a standard keyboard, is '1C', which is the code you are trying to send. Just sending Key A down, on it's own, will result in a continuous stream of A's being seen at the keyboard repeat rate.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|