Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

PS/2 Keyboard with C

Altera_Forum
Honored Contributor II
817 Views

Hello, 

 

i am trying to make a PS/2 Keyboard work with my FPGA and C language. 

 

I tried to capture sequences from the keyboard by using the following code : 

 

while(1) { while(1) { if(*ps2Data!=1) { printf("%d", *ps2Data); printf("%d", *ps2Data); printf("%d", *ps2Data); printf("%d", *ps2Data); printf("\n"); break; } } usleep(500000); } 

 

However the sequences that i had captured are not always the same for 1 key they can be the same for two different keys. 

For instance, when i pressed the 0 from the keypad it gave this (from the console) : 

0001 

0001 

0101 

0001 

0001 

0001 

0001 

 

And when i pressed the letter "N" i had : 

0001 

0101 

0001 

0001 

0001 

0001 

0001 

 

 

I know that there is a sequence when the key is pushed and an other one when the key is released, but i don't think that this is my problem. 

 

Actually i only need the 0-9 digits from the keypad which should be easier to implement (i guess). 

 

How could i do to capture the right sequences from the keyboard by using C ? 

 

Thank you for helping me :)
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
99 Views

What ps2Data is? Is it a pointer to the rx register of your ps2 serial port? 

Why do you read it 4 times? 

And, what's the meaning of if(*ps2Data!=1) ? 

Usually you need to test a "rx ready" bit on rx status register in order to know if new data word is available.
Reply