| ??? 08/19/04 15:57 Read: times |
#76181 - RE: debouncing code using vertical counters Responding to: ???'s previous message |
Impressed and curious, I had a go at implementing the algorithm in C. I took the opportunity to go one better and implement a 4-stage counter. Keil C51 does a very good job of generating code for this souce - just 30 instructions.
void fast_debouce( void ) small
{
static unsigned char vertical_counter_d = 0;
static unsigned char vertical_counter_c = 0;
static unsigned char vertical_counter_b = 0;
static unsigned char vertical_counter_a = 0;
unsigned char t;
//Increment the vertical counter.
vertical_counter_d = vertical_counter_d ^ ( (vertical_counter_a & vertical_counter_b) & vertical_counter_c );
vertical_counter_c = vertical_counter_c ^ (vertical_counter_a & vertical_counter_b);
vertical_counter_b = vertical_counter_b ^ vertical_counter_a;
vertical_counter_a = ~vertical_counter_a;
t = boucy_source ^ debouced_source;
vertical_counter_a = vertical_counter_a & t;
vertical_counter_b = vertical_counter_b & t;
vertical_counter_c = vertical_counter_c & t;
vertical_counter_d = vertical_counter_d & t;
t = ~t;
t = t | vertical_counter_a;
t = t | vertical_counter_b;
t = t | vertical_counter_c;
t = t | vertical_counter_d;
t = ~t;
debouced_source = debouced_source ^ t;
}
|
| Topic | Author | Date |
| debouncing code using vertical counters | 01/01/70 00:00 | |
| RE: debouncing code using vertical count | 01/01/70 00:00 | |
| RE: debouncing code using vertical count | 01/01/70 00:00 | |
| RE: debouncing code using vertical counters | 01/01/70 00:00 | |
| RE: debouncing code using vertical count | 01/01/70 00:00 | |
| RE: debouncing code using vertical counters | 01/01/70 00:00 | |
| RE: debouncing code using vertical count | 01/01/70 00:00 | |
| RE: debouncing code using vertical count | 01/01/70 00:00 | |
| RE: debouncing code using vertical counters | 01/01/70 00:00 | |
| RE: debouncing code using vertical count | 01/01/70 00:00 | |
| RE: debouncing code using vertical counters | 01/01/70 00:00 | |
RE: debouncing code using vertical counters | 01/01/70 00:00 |



