Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
05/17/01 10:20
Read: times


 
#11649 - RE: Timers&Counters
I suggest you work with an event-loop
cause why let your microcontroller wait and do nothing ...

Set a global-timer that overflows every 10 ms.

every then milliseconds you trigger the keyboard (switch) routine.

void key_status (void)
{
// check status
if P0.1 = 1 counter++;
else counter -= 2;

key = 0;

// check ranging
if (counter < 0)
counter = 0;
if (counter > DEBOUNCE_TIME)
{
counter = DEBOUNCE_TIME;
key = 1;
}
}

when you have several keys, you may want to use an array of chars !

An option may be a extra function that handles the key array to return an OR'ed key integer.


List of 19 messages in thread
TopicAuthorDate
Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      
RE: Timers&Counters            01/01/70 00:00      

Back to Subject List