??? 09/21/04 12:37 Read: times |
#77811 - Debounce, and define current problem Responding to: ???'s previous message |
Hi Craig, I think the error you speak of is the missing debounce but the assignment had two parts, write one program with debounce and one without. Actually the correction I remember had something to do with an address being wrong. Someone pointed out that the 8255 address was usually something else and you indicated that he was right. Either way my code doesn't seem to work. What is the current problem you are experiencing with the code you just posted (the one with debounce)? Does it constantly flash the LED, too? Is the flashing at a constant speed or is it sporadic? The professor recommended a 250ms delay for debounce, perhaps this is overkill but can it hurt? 250ms should be more than sufficient but looking at your code it doesn't really look like you're implementing debounce. Debounce means that you constantly read the value of the key and only consider it to be a valid keypress if the value doesn't change for a specific amount of time (250ms in your case). Normally what you do is read the value of the key. If the key was not pressed the last time you checked the key and now it is pressed you reset a counter. Then every time you read the key and determine that it is still pressed you increment the counter. You only consider the key as having been pressed if your counter reaches the debounce time. Pressing a key doesn't always result in an "instant on" but rather may result in a brief on, brief off, brief on, brief off, and then finally a constant "on" signal. The debounce logic makes sure the initial on/off noise is not counted as keypresses. Your code does not currently do that. It just has a delay so it only checks the key once every 250ms. That's not debounce. It just means your code will execute slower. Regards, Craig Steiner |