|
|
View previous topic :: View next topic |
Author |
Message |
guest Guest
|
password check routine , here |
Posted: Fri Jan 27, 2006 7:46 am |
|
|
I made this routine , and im using 4x4 keypad scand with the kbd.c library. It works very well , but the problem .
I need to get out of the loop after 15 secs .
I tried with Wt , but it dosnt wait long enough ,also i tried the Ds1302 , that is used in the circuit (real time clock) , but , it looks like the instruction kbd_getc(); , dosnt like to be executed in a loop with more instructions.....
please give me some hints....
C
//////////////////////////////////////////////////////////////////////
Void passwordcheck(){
Int segundo,timeout,checknum;
char word1,word2,word3,word4,
do {
lcd_putc("\fEnter your pass");
do {
word1=kbd_getc();
} while ((word1<'0') || (word1>'9'));
lcd_putc("\n *");
word1-='0';
do {
word2=kbd_getc();
} while ((word2<'0') || (word2>'9'));
lcd_putc("\n **");
word2-='0';
do {
word3=kbd_getc();
} while ((word3<'0') || (word3>'9'));
lcd_putc("\n ***");
word3-='0';
do {
word4=kbd_getc();
} while ((word4<'0') || (word4>'9'));
lcd_putc("\n ****");
word4-='0';
}
While((word1!=1) || (word2!=1) || (word3!=1) || (word4!=1));
} |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sat Jan 28, 2006 4:03 pm |
|
|
The function getc() will always wait for a character to arrive on the serial port before execution continues. For a possible solution have a look at the CCS manual, chapter 'How do I get getc() to timeout after a specified time?' (in the November 2005 version this is at page 260). |
|
|
guest Guest
|
|
Posted: Sun Jan 29, 2006 12:43 am |
|
|
mmm..but im not using the serial port , anyways... im using a keypad.... |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Sun Jan 29, 2006 9:40 am |
|
|
guest wrote: | mmm..but im not using the serial port , anyways... im using a keypad.... | My mistake, I was confused by the getc in the kbd_getc function name. However, the solution given for the getc function can be applied to your situation as well. |
|
|
micro2 Guest
|
|
Posted: Sun Jan 29, 2006 1:40 pm |
|
|
Use interrupt...
#int_TIMER1
TIMER1_isr()
{
if(cTimeOut1 != 0)
cTimeout1 --; //decrementa sino a 0 poi timeout
}
void main
....................
....................
//set Timer1
cTimeout = ?? (the correct value)
...................
...................
if(cTimeout==0)
return //exit function |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|