






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Traylor; Class: MICROPROCESSOR SYSTEM DESIGN; Subject: Electrical & Computer Engineer; University: Oregon State University; Term: Unknown 1989;
Typology: Study notes
1 / 12
This page cannot be seen from the preview
Don't miss anything!







Mechanical switches are one of the most common interfaces to a uC. Switch inputs are asynchronous to the uC and are not e lectrically clean. Asynchronous inputs can be handled with a synchronizer (2 FF's). Inputs from a switch are electrically cleansed with a switch debouncer. What is switch bounce? -The non-ideal behavior of the contacts that creates multiple electrical transitions for a single user input.
Switch bounce from the mega128 board pushbutton switches
Solutions -Analog filtering -usually an RC delay to filter out the rapid changes in switch output -task is to choose R and C such that input threshold is not crossed while bouncing is still occurring Vth in out in out 0V
Solutions -Cross coupled gates (MC14044) -logic gates lock in one transition with a single-pole, double-throw switch -both switch($3.69) and chip($0.38) are expensive -momentary click switches (ala AVR board) are ($0.12)
Solutions: -Count based -From Gansel's “Guide to Debouncing” -routine called from timer interrupt or delay loop -checks for Port D, bit 2, pushbutton depression, (bit will be grounded) -returns “1' only once per button push, “ pulsed output ” -acts like an edge detector int8_t debounce_switch() { static uint16_t state = 0; //holds present state state = (state << 1) | (! bit_is_clear(PIND, 2)) | 0xE000; if (state == 0xF000) return 1; return 0; } value of state first pass after reset: 1110 0000 0000 0001 return 0 after 12 false passes: 1111 1111 1111 1111 return 0 after 7 true passes: 1111 1111 1000 0000 return 0 after 12 true passes: 1111 0000 0000 0000 return 1 after many true passes: 1110 0000 0000 0000 return 0 after 5 false passes: 1110 0000 0001 1111 return 0
Solutions: -Digital filter based -acts like analog RC filter followed by schmitt trigger -nearly continuous output like an analog circuit
Sometimes we want a continuous output, e.g., organ keyboard. Other times we want a pulsed output, e.g. increment hour alarm. The first counting algorithm gives a pulsed output. The digital filter algorithm gives a continuous output. button push pulsed output continuous output
To get a pulsed output, from a continuous debouncer: pushed= always pushed=
output = 0 output = 0 output = 1