CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

HELP NEEDED..cannot send data using ps2 keyboard

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ecah



Joined: 06 Mar 2009
Posts: 2

View user's profile Send private message Send e-mail

HELP NEEDED..cannot send data using ps2 keyboard
PostPosted: Thu Mar 19, 2009 2:58 am     Reply with quote

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







PostPosted: Thu Mar 19, 2009 3:48 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 19, 2009 10:10 am     Reply with quote

In his previous post, six days ago, he was given several links to PS/2
code which he ignored.
http://www.ccsinfo.com/forum/viewtopic.php?t=38189
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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