FPGA Intellectual Property
PCI Express*, Networking and Connectivity, Memory Interfaces, DSP IP, and Video IP

Issue of PS/2 IP core

Altera_Forum
Honored Contributor II
1,205 Views

I have implement a porgram which show the key from keyboard on VGA, but now i meet a trouble. it show twice character whenever i press the keyboard. I try to set a breakpoint at the condition if (decode_mode == KB_ASCII_MAKE_CODE );, then everything work properly. But when I remove the break point it show the character twice.  

Can any one advice this? Thank you 

 

#include "system.h"# include "stdio.h"# include "altera_up_avalon_character_buffer.h"# include "altera_up_avalon_pixel_buffer.h"# include "altera_up_avalon_ps2.h"# include "altera_up_ps2_keyboard.h" /*Function that read keyboard input and show on monitor*/ void read_keyboard(alt_up_ps2_dev *ps2_kb, alt_up_char_buffer_dev *vga) { KB_CODE_TYPE decode_mode; alt_u8 buffer; int x = 0, y = 1; //If y start from 0 character will hide on the top of monitor char ascii; char *inputStr; alt_up_char_buffer_init(vga); alt_up_char_buffer_clear(vga); //Clear previous character on the screen while(1) { if (decode_scancode(ps2_kb, &decode_mode, &buffer, &ascii)==0) //If get a make code from keyboard { if (decode_mode == KB_ASCII_MAKE_CODE ); { translate_make_code(decode_mode, buffer, inputStr); //translate the code like "SPCAE", "BACKSPACE" alt_up_char_buffer_string(vga, inputStr, x,y); x++; if (x > 80) { y++; x = 0; } if (y > 60) { y = x = 0; } } } } } int main(void) { alt_up_ps2_dev *ps2 = alt_up_ps2_open_dev("/dev/up_avalon_ps2_0"); //open PS/2 device alt_up_ps2_init(ps2); alt_up_ps2_clear_fifo(ps2); alt_up_char_buffer_dev *vga = alt_up_char_buffer_open_dev("/dev/up_avalon_character_buffer_0");//open vga device if (ps2->device_type == PS2_KEYBOARD) //Check if the device connected to PS/2 is keyboard { read_keyboard(ps2, vga); } else { printf("Error...\n"); return -1; } }
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
473 Views

have you solve the problem?

0 Kudos
Altera_Forum
Honored Contributor II
473 Views

I am having this same problem. I'm also calling decode_scancode() in a while(1) loop, and it always gives me to make codes (press and release), never any break codes. 

 

Anyone else have this issue? My code is essentially the same as ctkhai's  

 

Regards, 

Jonathon
0 Kudos
Altera_Forum
Honored Contributor II
473 Views

Hi all, where did you get altera_up_avalon_character_buffer.h? 

 

I am not finding this file in my PC at all.
0 Kudos
Altera_Forum
Honored Contributor II
473 Views

@waiyung, Do you have the University Program IP packages installed? Anything with "_up" in it is referring to University Program.

0 Kudos
Altera_Forum
Honored Contributor II
473 Views

By the way, all, this is definitely some sort of timing issue. I too got it to work while debugging and stepping through the program, but not running at full 16MHz. I wondering if its managing to pull the same code from the buffer twice before it is cleared or something. I know it's not elegant, but inserting some sleep (somewhere, I can't remember now) did the trick.

0 Kudos
Altera_Forum
Honored Contributor II
473 Views

Yes, I have UP package installed. But it does not have the header file altera_up_avalon_character_buffer.h 

 

I double checked it by searching through my PC. This file is not there. But I found altera_up_avalon_video_character_buffer_with_dma.h 

 

Also, in the system file, I cannot find the character_buffer either. Any idea?
0 Kudos
Reply