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 https://www.google.rs/imgres?q=wavefo...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!
#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;
}
}
}
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 https://www.google.rs/imgres?q=wavefo...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!
#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;
}
}
}