Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PS2 keyboard and LCD connect to 8051

Status
Not open for further replies.

vuckoliki

Newbie level 1
Joined
Dec 19, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
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 Упозорење о пребацивању

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;
}
}
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top