1 / 17

ECE3120: Chapter 7- Parallel Ports Interfacing with simple input devices

. Prev

jirair
Download Presentation

ECE3120: Chapter 7- Parallel Ports Interfacing with simple input devices

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. ECE3120: Chapter 7- Parallel Ports Interfacing with simple input devices Dr. Xubin He http://iweb.tntech.edu/hexb Email: hexb@tntech.edu Tel: 931-3723462, Brown Hall 319

    2. Prev… Interfacing with Simple Output devices Today… Interfacing with simple input devices

    3. Interfacing with DIP Switches Switches are often grouped together. It is most common to have four or eight switches in a DIP package. DIP switches are often used to provide setup information to the microcontroller. After power is turned on, the microcontroller reads the settings of the DIP switches and performs accordingly.

    4. Interfacing with DIP Switches Example 7.9 Write a sequence of instructions to read the value from an eight-switch DIP connected to PORTA of the HCS12 into accumulator A. Solution

    5. Interfacing to a Keyboard A keyboard is arranged as an array of switches, which can be mechanical, membrane, capacitors, or Hall-effect in construction. Mechanical switches are most popular for keyboards. Mechanical switches have a problem called contact bounce. Closing a mechanical switch generates a series of pulses because the switch contacts do not come to rest immediately. In addition, a human cannot type more than 50 keys in a second. Reading the keyboard more than 50 times a second will read the same key stroke too many times. A keyboard input is divided into three steps: Scan the keyboard to discover which key has been pressed. Debounce the keyboard to determine if a key is indeed pressed. Both hardware and software approaches for key debouncing are available. Lookup the ASCII table to find out the ASCII code of the pressed key.

    6. Hardware Debouncing Techniques SR latches Non-inverting CMOS gates Integrating debouncer

    7. Software Debouncing Technique The most popular and simple one has been the wait and see method. In this method, the program simply waits for about 10 ms and reexamines the same key again to see if it is still pressed.

    8. ASCII Code Table Lookup The ASCII code of each key can be stored in a table for easy look up. keytab db "0123456789“ db … Getcode ldab keyboard andb #$3f ;compute the address ;typo in the textbook ldx #keytab ldaa b,x …

    9. Interfacing the HCS12 to a Keypad A keypad usually consists of 12 to 24 keys and is adequate for many applications. Like a keyboard, a keypad also needs debouncing. A 16-key keypad can be easily interfaced to one of the HCS12 parallel ports. A circuit that interfaces a 16-key keypad is shown in Figure 7.41. In this Figure, pins PA7..PA4 each control four keys.

    10. Example 7.10 Write a program to perform keypad scanning, debouncing, and returns the ASCII code in accumulator A to the caller. Solution Pins PA4..PA7 each control one row of four keys. Scanning is performed by setting one of the PA7..PA4 pins to low, the other three pins to high and testing one key at a time.

    18. Next… Interfacing with D/A converters

More Related