Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue Dec 23, 2014 10:12 am |
|
|
It's all down to timings, and working out what they are.
This section tells you how to set up:- Code: | #define KBD_DEBOUNCE_FACTOR 33 // Set this number to apx n/333 where
// n is the number of times you expect
// to call kbd_getc each second |
How many times per second do you expect to go round your loop?
These lines each take ~1.2ms
Code: | lcd_gotoxy(1,1);
printf(lcd_putc, "%c",k);
|
This one ~10ms
Code: | printf(LCD_PUTC,"%05ld ",dat); |
With these lines in place:-
Code: | dat++;
lcd_gotoxy(10,3);
printf(LCD_PUTC,"%05ld ",dat); |
You're going round at once in slightly over 11ms.
So your n is ~90.
In my book the calculation n/333 does NOT yield 33.
Now do you see where the problem is?
Mike |
|