PS2 keyboard and LCD connect to 8051

Thread Starter

vuckoliki

Joined Dec 19, 2011
1
Hi,
below is a simple code for Atmel 8051 connected with PS2 keyboard and LCD display. I want to take ASCII value from keyboard and displey it on LCD but i have problem with cnt1.

Keyboard clk is connected on extern interrupt 1, port P3.3. And data value is taken from port P3.4.

By looking picture http://www.google.rs/imgres?q=waveform+PS2&hl=sr&client=firefox-a&hs=niJ&rls=org.mozilla:en-US:official&biw=1366&bih=625&tbm=isch&tbnid=K-yqLOG-yEOpPM:&imgrefurl=http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2010/jmd344_aes89/andy/andy/TacoHTMLEditTemp.html&docid=E1PwUUPfFHC1rM&imgurl=http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2010/jmd344_aes89/andy/andy/ps2%252520waveform.bmp&w=628&h=335&ei=9pnrTrLaDcrdsgbZuKzJBw&zoom=1&iact=hc&vpx=160&vpy=166&dur=2999&hovh=164&hovw=308&tx=178&ty=90&sig=101865074713422734129&page=1&tbnh=100&tbnw=187&start=0&ndsp=21&ved=1t:429,r:0,s:0http://www.google.rs/imgres?q=waveform+PS2&hl=sr&client=firefox-a&hs=niJ&rls=org.mozilla:en-US:official&biw=1366&bih=625&tbm=isch&tbnid=K-yqLOG-yEOpPM:&imgrefurl=http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2010/jmd344_aes89/andy/andy/TacoHTMLEditTemp.html&docid=E1PwUUPfFHC1rM&imgurl=http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2010/jmd344_aes89/andy/andy/ps2%2520waveform.bmp&w=628&h=335&ei=9pnrTrLaDcrdsgbZuKzJBw&zoom=1&iact=hc&vpx=160&vpy=166&dur=2999&hovh=164&hovw=308&tx=178&ty=90&sig=101865074713422734129&page=1&tbnh=100&tbnw=187&start=0&ndsp=21&ved=1t:429,r:0,s:0

my conclusion is that cnt1 must be reset on cnt1=11 but i am not sure in that.

If anyone have more experience and can see error , please write something....thx!

Rich (BB code):
#define uchar unsigned char
#define uint unsigned int
 
uchar cnt1=0; //
bit write=0;
sbit kbd_data=P3^4;
unsigned char array1=0;
uchar bafer=0;
 
void init (void)
{
   LCD16xx_init();
}
 
void TimerXXX (void) interrupt 2
{
   bafer=kbd_data;
 
   if ((cnt1>0) && (cnt1<9))
   {
       bafer=bafer<<(cnt1-1);
   }
 
array1^=bafer;
cnt1++;
 
if(cnt1==33) //????????
 {
    cnt1=0;
    write=1;
    EX1 = 0;
 }
}
 
void main(void)
{
   uchar cnt2=0;
   EA=1;
   EX1=1;
   init();
 
while(1)
 {
   if (write==1)
    {
       LCD16xx_write_charPos(cnt2,0, 0, array1 ); //(cnt2=cursor position,0=line number...)
       cnt2++;
       array1=0;
       write=0;
       EX1 = 1;
     }
 }
}
 
Last edited by a moderator:
Top