UF EEL 4744 - Lab #5: Software Switch Debounce & CPLD Programming

Unformatted text preview:

University of Florida EEL 4744 Department of Electrical and Computer Engineering Page 1/2 Lab #5: Software Switch Debounce & CPLD Programming Purpose This lab consists of adding debounce software for the keypad added in Lab #4. The final goal of this lab is to modify the CPLD schematic file that was provided earlier this semester (CPLD decode equation for your boards EPROM). Both the debounce software and CPLD modifications sections of this lab must be complete by the end of this lab. Part I. Deboucing a Switch via Software In Lab #4, you added a keypad to your 68HC12 development board and wrote software to immediately illustrate the key pressed on a LED binary display. We will now use the same hardware as before and only modify the software to do the following: 1. Check when the "1" key is pressed on your keypad. 2. Every time the "1" key is pressed, increment a counter and display the contents of this counter on your binary display added in the last lab. 3. If a "0" is pressed, zero out the counter value. Because we are now counting the number of keystrokes, we will need to debounce the keypad switches. This step is necessary because when a key is pressed or released, the contacts of the switch bounce between the switch being open and closed repeatedly for several milliseconds. This in turn causes your input relating to this switch to bounce between L (switch is closed and shorted to ground) and H (switch is open and pull-up resistor pulls input high). However, we only want a count of one every time a key is pressed and released. Note: In our last lab we were only interested in which key was pressed and not how many times it was pressed. Thus, if a key was pressed multiple times (switch bounce) in a few milli-seconds, our display was immediately updated with this information on the first HLH transition of the bounce and all other transitions did not change or affect the display because the display now reflects the new information (key pressed). To remove switch bounce via software, we simply put in a time delay to allow the switch to settle after it has been pressed and after it has been released. Therefore, you should: 1. Test for a key pressed. 2. If pressed, delay 50-100 msec and then update or clear counter. 3. Check when the key is released and again delay before going back to #1. Part II. Altering the CPLD Decode File The purpose of this exercise is to refresh your memory on how to modify and create schematic entry files in Quartus II. If you do not know how to use the Quartus II software you will need to consult the tutorial for this software during TA’s office hours. In this Lab, we will use this software to add an inverter to the existing CPLD design. The input for the inverter will be a single binary switch (with pull-up resistor) and the output will be an LED (with current limiting resistor). The CPLD (7032 device from Altera) is used to decode address and control lines (E clk, R/-W) from the 6812 to enable the boot EPROM. This was programmed earlier by your TA. We will now re-create this file under Quartus II and add an inverter. The procedure is as follows: 1. Add an inverter to the EPROM decode circuit and make sure you use an input assigned to an open pin on the CPLD. Also make sure the output is assigned to another open pin on the CPLD. You will have to consult the 6812 board manual to see which pins are available for use and where they go (CPLD header pin number). 2. Use your byte blaster clone to program the CPLD directly in the 68HC212 board or… Carefully pull out your CPLD (make a note as to the direction of Pin1 on the device andUniversity of Florida EEL 4744 Department of Electrical and Computer Engineering Page 2/2 Lab #5: Software Switch Debounce & CPLD Programming orientation in the socket) and program it using your 7032 board from EEL3701. Now place the chip back in its original socket in the proper orientation. 3. Connect a single binary switch (you should have one open from the group of switches you installed in a previous lab) and pull-up resistor (680 – 3.3K ohms is fine) to the input of the inverter you added in the CPLD. 4. Connect a single (330-680 ohm) current limiting resistor to the output of the inverter. Now attach this to an LED for display. 5. Verify that when you toggle the new switch it toggles the LED. Note1: You are responsible for the pull-up resistor, current limiting resistor and LED parts. If you don’t have them or can’t figure out how to use open parts already on your board, go to a local electronic shop and buy them. Resistors are very cheap! Part I. In-Lab Requirements: 1. Upon entering the lab, show error-free ASM and list files to your TA for Part I (debounce software). This is pre-lab material. 2. Disable your delay in your software and use the Logic State Analyzer (LSA) to trigger when the "1" is pressed. Observe the switch bounce on the LSA. Measure the duration of the bounce. 3. Next trigger the LSA when the key is released and again observe and measure the bounce. 4. Run your code with the delay and show that your program debounces the switch, counts properly, and clears when required. 5. Now use the LSA to precisely measure the duration of your delay routine: A. Select an open pin from one of the available port pins and configure it for output. B. Set the debug output pin low before a key is pressed. C. Set the output high immediately before entering the delay routine. D. Set the output pin low after leaving the delay routine. E. Add this debug output signal to your LSA and measure how long it is high once a pressed key triggers the analyzer. Part II. In-Lab Requirements: 1. Show your TA a printout of the CPLD schematic entry file. (Pre-Lab Materials) Also bring everything on diskette. 2. Demonstrate to your TA that the inverter is functional by switching the binary switch on/off with the LED changing to the appropriate value. 3. The TA will now give you new pins for the inverter's inputs and outputs. Change these in the CPLD decode file, program the device, remove the old wires going to your binary switch and LED current limiting resistor and add new wire from the new pin locations to your input switch and current limiting LED resistor. 4. Demonstrate to the TA the inverter is functional by changing the input switch and observing the change on the LED. Point Breakdown: Part I.


View Full Document

UF EEL 4744 - Lab #5: Software Switch Debounce & CPLD Programming

Download Lab #5: Software Switch Debounce & CPLD Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab #5: Software Switch Debounce & CPLD Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab #5: Software Switch Debounce & CPLD Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?