Keypad interfacing problem.

Status
Not open for further replies.

HerohetoChakma

Junior Member level 3
Joined
Apr 19, 2013
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Chittagong, Bangladesh.
herohetoc.webs.com
Activity points
2,338
I have designed a program in which i can set my desire set point by keypad. When i simulate this is work sometimes but sometimes it does not work. That means i can set my desire set point by trying more times. But every key is ok, they work all some times, When i simulate my program i can see a meassage that simulation can not run due to excessive load. How can i solve this problem? Could anyone help me?
 

This is my code. By this code i can set my desire set point by a keypad. But sometimes it does not work but all key are ok. Sometime it work properly by trying more times. When i simulate there is an error message that simulation can't run due to excessive cpu load. Where is my problem? Can anyone help me please? is there i have to declar #include<delay.h> function? I have not declare this in my program.

// Keypad scanning functions
//=============================================================================
void clearrow1(void) //clear the 1st row and set the others
{
RC7=0;
RC6=1;
RC5=1;
RC4=1;
}
void clearrow2(void) //clear the 2nd row and set the others
{
RC7=1;
RC6=0;
RC5=1;
RC4=1;
}
void clearrow3(void) //clear the 3rd row and set the others
{
RC7=1;
RC6=1;
RC5=0;
RC4=1;
}
void clearrow4(void) //clear the 4th roW and set the others
{
RC7=1;
RC6=1;
RC5=1;
RC4=0;
}
void scancolumn1(void)
{
if(RC0==0) //if key '1' is being pressed
{
while(RC0==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st word
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of nuum_count //variable
send_char('1'); //Display the symbol '1' at LCD
keyin[num_count]='1'; //Stall the '1' value at the keyin array
num_count+=1; //increase the num_count variable's value by 1 //and the result stall back to the variable
}
else if(RC1==0) //if key '2' is being pressed
{
while(RC1==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('2'); //Display the symbol '2' at LCD
keyin[num_count]='2'; //Stall the '2' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
else if(RC2==0) //if key '3' is being pressed
{
while(RC2==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('3'); //Display the symbol '3' at LCD
keyin[num_count]='3'; //Stall the '3' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
}
void scancolumn2(void)
{
if(RC0==0) //if key '4' is being pressed
{
while(RC0==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('4'); //Display the symbol '4' at LCD
keyin[num_count]='4'; //Stall the '4' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
else if(RC1==0) //if key '5' is being pressed
{
while(RC1==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('5'); //Display the symbol '5' at LCD
keyin[num_count]='5'; //Stall the '5' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
else if(RC2==0) //if key '6' is being pressed
{
while(RC2==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('6'); //Display the symbol '6' at LCD
keyin[num_count]='6'; //Stall the '6' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
}
void scancolumn3(void)
{
if(RC0==0) //if key '7' is being pressed
{
while(RC0==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('7'); //Display the symbol '7' at LCD
keyin[num_count]='7'; //Stall the '7' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
else if(RC1==0) //if key '8' is being pressed
{
while(RC1==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('8'); //Display the symbol '8' at LCD
keyin[num_count]='8'; //Stall the '8' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
else if(RC2==0) //if key '9' is being pressed
{
while(RC2==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('9'); //Display the symbol '9' at LCD
keyin[num_count]='9'; //Stall the '9' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
}
void scancolumn4(void)
{
if(RC0==0) //if key '*' is being pressed
{
while(RC0==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('*'); //Display the symbol '*' at LCD
keyin[num_count]='*'; //Stall the '*' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
else if(RC1==0) //if key '0' is being pressed
{
while(RC1==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('0'); //Display the symbol '0' at LCD
keyin[num_count]='0'; //Stall the '0' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
else if(RC2==0) //if key '#' is being pressed
{
while(RC2==0)continue; //waiting the key to be released
if(num_count==0)lcd_clr(); //Clear the LCD if the key is the 1st password
lcd_goto(num_count); //The cursor of LCD points to the column //equivalent to the value of password_count //variable
send_char('#'); //Display the symbol '#' at LCD
keyin[num_count]='#'; //Stall the '#' value at the keyin_char array
num_count+=1; //increase the Password_count variable's value //by 1 and the result stall back to the variable
}
}
 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…