LCD tipkovnica i sučelje

A

ashugtiwari

Guest
Hi All,
Ja sam koristeći tipkovnicu preko prioritet koder i LCD u 4-bitnom modu sa P89LV51 kontroler.Kod pojedinih je rad prekid za tipkovnicu i LCD, ja imati 6 tipke na tipkovnici kroz koder.Našto ja prisutan samo jednu tipku i pritisnite drugu tipku nakon suffucuent odlaganja (više od 200ms) ključ je ispravno prikazati ansd prihvaćen od strane kontrolora, ali dok ja iznenada pritisnite jednu ili bilo koju tipku na bržim tempom, nema odgovor od kontrolera, to prikazuje ništa.Pokušao sam na debounce prilagodbu, ali ipak se ponekad čini da rade, ali opet nakon nekog vremena počinje isto ponašanje.Ako netko ima robustan i stabilan kod plz odgovor.
Hvala
Ashutosh

 
Mislim da je to protok:
provjeriti s / w press - otkazati šiba - prikaz na lcd - loop

post kod

 
/ * Kod za LCD tipkovnica i sučelje * /

# include "at898252.h"
# define lcd_io P0 / / P2

sbit rs_lcd = P1 ^ 3; / / P3_5
sbit rw_lcd = P1 ^ 4; / / P3_6
sbit e_lcd = P1 ^ 2; / / P3_7
sbit kl_sel = P3 ^ 4;
unsigned char xdata new_key = 0, key_count, naredba, računati, PARAM_DATA [25];
bit key_mode0 = 1, key_mode1 = 0, process_command = 1, key_pressed;

void lcd_chk_busy ();
void soft_dly_1ms (unsigned short);

void soft_dly_1ms (unsigned short dly)
(
unsigned int j;
while (dly -! = 0)
for (j = 0; j <= 82; j );
)

void lcd_wrt_cmd (unsigned char cmd)
(
lcd_chk_busy ();
rs_lcd = 0;
rw_lcd = 0;
lcd_io & = 0x0f;
e_lcd = 1;
lcd_io | = (& 0xf0 cmd);
e_lcd = 0;
lcd_io & = 0x0f;
e_lcd = 1;
lcd_io | = ((cmd <<4) & 0xf0);
e_lcd = 0;
soft_dly_1ms (2);
)

void lcd_wrt_char (unsigned char ch)
(
lcd_chk_busy ();
rs_lcd = 1;
rw_lcd = 0;
lcd_io & = 0x0f;
e_lcd = 1;
lcd_io | = (ch & 0xf0);
e_lcd = 0;
lcd_io & = 0x0f;
e_lcd = 1;
lcd_io | = ((ch <<4) & 0xf0);
e_lcd = 0;
soft_dly_1ms (2);
)

void lcd_wrt_string (unsigned char * str)
(
unsigned char i = 0;
while (str ! = '\ 0')
(
lcd_chk_busy ();
rs_lcd = 1;
rw_lcd = 0;
lcd_io & = 0x0f;
e_lcd = 1;
lcd_io | = (str & 0xf0);
e_lcd = 0;
lcd_io & = 0x0f;
e_lcd = 1;
lcd_io | = ((str [i ] <<4) & 0xf0);
e_lcd = 0;
soft_dly_1ms (2);
)
)

lcd_chk_busy void ()
(
rs_lcd = 0;
rw_lcd = 1;
ponoviti:
soft_dly_1ms (2);
e_lcd = 1;
if (P0_7)
(
e_lcd = 0;
goto repeat;
)
e_lcd = 0;
)

lcd_init void ()
(
lcd_wrt_cmd (0x01); / / jasan prikaz
lcd_wrt_cmd (0x02); / / povratak kući
lcd_wrt_cmd (0x06); / / adresa prirast bez prikaza pomak
lcd_wrt_cmd (0x0f); / / prikaz na, pokazivač dana, trepnuti na
lcd_wrt_cmd (0x14), / / pokazivač desno pomak
lcd_wrt_cmd (0x28); / / 4-bitno sučelje, 2 linije zaslona i 5x8 znakova fonta
lcd_wrt_cmd (0x80); / / dodaj u 1. redak 1. char
)

system_init void ()
(
IE = 0x93;
IT0 = 1;
TMOD = 0x21;
TH0 = 0xb8;
TL0 = 0x00;
kl_sel = 0;
TH1 = 0xff; / / FD-9600 baud PCON = 00h
TL1 = 0xff; / / FF-57600 baud PCON = 80h
/ / PCON = 0x80;
/ / SCON = 0x58;
/ / TR1 = 1;
)

void serial_int () prekinuti 4 koristi 2
(
if (TI)
(
TI = 0;
SBUF = new_key '0 ';
ES = 0;
)
if (RI)
(
RI = 0;
ES = 1;
)
)

void keyboard_int0 () 0 prekinuti koristi 0
(
EA = 0;
P1 | = 0x1c;
new_key = 0;
/ / TI = 0;
/ / ES = 1;
kl_sel = 1;
soft_dly_1ms (80);
if (P3_2)
(
goto end;
)
drugi
(
new_key = (~ (P1>> 2)) & 0x07;
key_pressed = 1;
)
while (P3_2 == 0);
Kraj:
soft_dly_1ms (80);
kl_sel = 0;
P1 = & 0xe3;
EA = 1;
)

void main (void)
(
/ / Unsigned char i;
system_init ();
lcd_init ();
while (1)
(
if (key_pressed)
(
key_pressed = 0;
if ((new_key> = 0) & & (new_key <= 5))
(
PARAM_DATA [i ] = new_key '0 ';
PARAM_DATA = '\ 0';
lcd_init ();
lcd_wrt_cmd (0x02);
soft_dly_1ms (10);
lcd_wrt_string (PARAM_DATA);
/ / TI = 1;
)
/ / If (i> 15)
/ / I = 0;
)
)
)
/ * provjeriti kod za bilo koju pogrešku, ja sumnja debounce problem * /

 

Welcome to EDABoard.com

Sponsor

Back
Top