Example 6 Hex Keypad Lecture L3.2.

Slides:



Advertisements
Similar presentations
Introduction to Assembly language
Advertisements

C Examples 1.
Example 11 Analog-to-Digital Converter Lecture L5.1.
7-1 Keypad Scanning interface Used for interfacing push-button(momentary) switches Used for large number(>8) push-buttons Relies on matrix arrangement.
Programming I/O for Embedded System. Page 2 Overview Basis: A DE2 Computer Architecture Parallel I/O 7-Segment Display Basic Manipulating 7-Segment Display.
 C is general-purpose structured programming language or high level language.  It was developed by Dennis Ritchie in 1970s at Bell laboratories. 
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
1 4-Integrating Peripherals in Embedded Systems (cont.)
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
The miniDragon+ Board and CodeWarrior Lecture L2.1.
Franz Duran INTRODUCTION TO A RDUINO PROGRAMMING & INTERFACING Engr. Franz Duran, MEP-ECE RapidSignal Electronics.
Engineering 1040: Mechanisms & Electric Circuits Winter 2015 Introduction to C Programming.
Parallel Interfacing Chapter 7. Parallel Interfacing Parallel I/O Ports Using Parallel Ports Seven-Segment Displays Keypad Interfacing Liquid Crystal.
ECE 371 – Unit 9 Interrupts (continued). Example Set up Two Interrupt Request Inputs: –Port H[0] Set Interrupt Flag on “0” to “1” transition (rising edge)
Serial Communication Interface Ta Kim Nicholas Earnhart Razid Ahmad ME 6405 – Fall 2008 November 6, 2008.
AVR Programming: Digital I/O September 10, What is Digital I/O? Digital – A 1 or 0 Input – Data (a voltage) that the microcontroller is reading.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Example 11 Analog-to-Digital Converter Lecture L5.1.
Example 12 Pulse-Width Modulation (PWM): Motors and Servos Lecture L8.1.
Saxion University of Applied Sciences Advanced Microcontrollers A practical approach.
Input Interface – Microprocessor
Programming Microcontrollers in C Lecture L7.1. C Data Types TypeSizeRange char1 byte-128 – 127 unsigned char1 byte0 – 255 Int2 bytes – unsigned.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
Wireless TYWu. 433Mhz RF link kit Picture 433Mhz RF link kit Specification –Frequency: 433Mhz. –Receiver Data Output: High - 1/2 Vcc, Low - 0.7v –Transmitter.
INTERNET OF EVERYTHING SDU 2016 Week 4. Simple Digital and Analog Inputs  The Arduino’s ability to sense digital and analog inputs allows it to respond.
Yared Woldekiros Western Washington university WEB ENABLE HOME AUTOMATION.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
ECE 447: Lecture 12 Keypads ECE 447: Lecture 10. ECE 447: Matrix Keypad.
Examples Lecture L2.2. // Example 1a: Turn on every other segment on 7-seg display #include /* common defines and macros */ #include /* derivative.
Vishwakarma government engineering college Prepare by. Hardik Jolapara( ) LCD Interfacing with ATmega16.
Microprocessors A practical approach..
INTERFACING KEYBOARD WITH ATMEGA32 ELECTRONICS & COMMUNICATION TITLE.
Assist. Prof. Rassim Suliyev - SDU 2017
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
4-Integrating Peripherals in Embedded Systems (cont.)
Input/Output Ports and Interfacing
Example 14 Real-time Interrupts
Build a microSD Bootloader using a PIC microcontroller
Get Your Project Started with Arduino
4-Integrating Peripherals in Embedded Systems
European Robotic LABoratory
Example 19 Measuring Pulse Widths Using Interrupts
4-Integrating Peripherals in Embedded Systems
Session 3,4.
ECET 330 Innovative Education--snaptutorial.com
Example 10 ASCII String to Binary Conversion
Example 5 Pushbutton Switches: S1 and S2
Lecture 22.
2) Connect the VGA cable from the monitor output of the laptop [D] to the computer input of the projector [E]. [D] [E]
Example 9 Binary to ASCII String Conversion
COMP2121: Microprocessors and Interfacing
Example 15 Interrupt-Driven Controller
Microcontrollers and Microprocessors
Master I/O Connectors PL12 PL14 PL21 PL20 PL17.
Interrupts in C Programs
Example 16 Circular Queue
Example 13 The Serial Peripheral Interface (SPI)
Analog-to-Digital Converters
82C55 Programmable Peripheral Interface
AVR Programming in C Chapter 7
Example 17 SCI Receive Interrupts
Example 7 Liquid Crystal Display
EE4OI4 Engineering Design
Example 18 Pulse Train Using Interrupts
PIC16F887.  1.Microcontroller introducton  2.MPLAB,Hi-tech compilers  3.LED  4.Switches/push buttons  5.7-Segment Display  6.Keypad  7.LCD  8.Timers.
컴퓨터 프로그래밍 기초 - 13th : 마지막 수업 -
Interfacing keyboard with FPGA
Presentation by Anthony Dotterer
Presentation transcript:

Example 6 Hex Keypad Lecture L3.2

miniDragon+ 2 pushbutton switches Serial cable A/D Pot I/O headers Run/Load switch Reset button 7-segment display Power plug Keypad header

4 x 4 Hex Keypad

4 x 4 Hex Keypad

int key_scan(void) int key_scan(void){ const char keycodes[] = { 0xD7,0xEE,0xDE,0xBE, 0xED,0xDD,0xBD,0xEB, 0xDB,0xBB,0x7E,0x7D, 0x7B,0x77,0xE7,0xB7 }; int i,j, key; char readback; int found; i = 0; key = 16; // return 16 if no key pressed found = 0; while((i < 16) && (found == 0)){ PORTA = keycodes[i]; // write keycode to PORTA for(j = 0; j<10; j++){ } // wait a bit readback = PORTA; if(readback == keycodes[i]){ // read back PORTA, if same key = i; // get key number found = 1; // and exit loop } else i++; // else check next key return key; // return key int key_scan(void)

void wait_for_keyup(void) int get_key(void) int get_key(void){ int key; do { key = key_scan(); } while(key == 16); return key; void wait_for_keyup(void){ while(key_scan() != 16){ void wait_for_keyup(void)

Example 6a // Example 6a: 4 x 4 keypad in C #include <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" int key_scan(void); int get_key(void); void wait_for_keyup(void); void main(void) { int c; PLL_init(); // set system clock frequency to 24 MHz seg7_enable(); // enable 7-segment display DDRA = 0x0F; // Port A: A7:A4 inputs, A3:A0 outputs while(1){ c = get_key(); seg7dec(c); wait_for_keyup(); }

Example 6

Example 6b // Example 6b: 4 x 4 keypad using C function calls #include <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* derivative information */ #include "main_asm.h" /* interface to the assembly module */ #pragma LINK_INFO DERIVATIVE "mc9s12dp256b" void main(void) { char c; PLL_init(); // set system clock frequency to 24 MHz seg7_enable(); // enable 7-segment display keypad_enable(); while(1){ c = getkey(); seg7dec(c); wait_keyup(); }