| ??? 08/21/08 15:24 Read: times |
#157634 - I see ... Responding to: ???'s previous message |
... a few possible problems.
bit debounce=1;
bdata unsigned char row_no,col_no;
sbit col_no0 = col_no^0;
void delay(unsigned int itime)
{
int i,j;
for(i=0;i<1275;i++) <--------- Do you want to do this, or do you want the loops nested?
;
for(j=0;j<itime;j++)
;
}
:
:
:
:
unsigned char key_scan()
{
unsigned char temp,i,key=100;
col=0xff;
row=0x00;
while(col==0xff)
; <--------- This is going to loop forever!
temp=col;
delay(20);
while(col==0xff)
; <--------- So is this!
if(temp!=col)
{
debounce=0;
}
else
{
delay(20);
temp=0xfe;
for(i=0;i<8;i++)
{
row=_crol_(temp,i);
if(col != 0xff)
{
col_no=col;
col_check();
key=key_matrix[col_no];
col=0xff;
while(col!=0xff)
; <--------- And this!
return key;
}
}
}
}
Unless col is being changed in an interrupt routine that was not shown, your while loops will loop forever. Personally, I ALWAYS put the semicolon after a while() or for() statement on a separate line. Otherwise it is too easy for the reader's brain to skip over that little mark. When it is on a separate line, I KNOW that I wanted the code to do nothing inside the loop. In fact, I use a macro: #define donothing ; to show that I really, truly do not want to do anything in the loop. --Rich |
| Topic | Author | Date |
| problem in 8x8 keypad | 01/01/70 00:00 | |
| I see ... | 01/01/70 00:00 | |
| this code with correction | 01/01/70 00:00 | |
| Try the Insert Code button. | 01/01/70 00:00 | |
| code with comment | 01/01/70 00:00 | |
| Lots of things to look into | 01/01/70 00:00 | |
| reply | 01/01/70 00:00 | |
| One way to debounce | 01/01/70 00:00 | |
| One Suggestion | 01/01/70 00:00 | |
| the easy way to do keypads | 01/01/70 00:00 | |
| indent, indent, indent | 01/01/70 00:00 | |
| problem in keypad | 01/01/70 00:00 | |
| Where is the code? | 01/01/70 00:00 | |
| code of 8x8 keypad | 01/01/70 00:00 | |
Simplify and think about debounce | 01/01/70 00:00 |



