FND, Keypad 사용 계산기 설계 20072413 박민호.

Slides:



Advertisements
Similar presentations
Wilga 2006 Pi of the Sky data transmission Janusz Użycki Faculty of Physics Warsaw University of Technology.
Advertisements

Lecture Computer Science I - Martin Hardwick The Programming Process rUse an editor to create a program file (source file). l contains the text of.
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Chapter 4 Section 3 Matrix Multiplication. Scalar Multiplication Scalar Product - multiplying each element in a matrix by a scalar (real number) –Symbol:
Recursive Descent Technique CMSC 331. UMBC 2 The Header /* This program matches the following A -> B { '|' B } B -> C { '&' C } C -> D { '^' D } D ->
Mr. Banyat Somsupan ubonTecnical Unit 2. Electronic Ubontecnical.
Vervolg C Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology 1 Onderwerpen voor vandaag Dallas one-wire interface Opgave:
The 8051 Assembly Language Stack, Bit Addressing, Arithmetic
The Practice of Micro-processor Yonam Institute of Digital Technology 04. FND (7-Segment) Control.
The Practice of Micro-processor Yonam Institute of Digital Technology 05. Key Matrix Control.
The Practice of Micro-processor Yonam Institute of Digital Technology 06. LCD Control.
The Practice of Micro-processor Yonam Institute of Digital Technology 03. Preparing for Practice.
2 x0 0 12/13/2014 Know Your Facts!. 2 x1 2 12/13/2014 Know Your Facts!
2 x /10/2015 Know Your Facts!. 8 x /10/2015 Know Your Facts!
13-1 Bard, Gerstlauer, Valvano, Erez, Telang, Yerraballi EE 319K Introduction to Embedded Systems Lecture 13: 2-D Arrays, Bitmaps, Sprites, Structs, Lab.
Programming the C8051F020 Using C Language
Christo Wilson Project 2: User Programs in Pintos
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt WHILE.
1 Lecture 5 PRAM Algorithm: Parallel Prefix Parallel Computing Fall 2008.
5 x4. 10 x2 9 x3 10 x9 10 x4 10 x8 9 x2 9 x4.
0 x x2 0 0 x1 0 0 x3 0 1 x7 7 2 x0 0 9 x0 0.
Asst. Prof. Dr. Alper SISMAN
Air Force Institute of Technology Electrical and Computer Engineering
C Examples 1.
Flow Diagram: Push flags, CS, IP Pop IP,CS,flags Push AX,BX,CX,DX,ES,DS,SI,DI,BP POP BP,DI,SI,DS,ES,DX,CX,BX,AX.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
Overview creating your own functions calling your own functions.
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
7-1 Keypad Scanning interface Used for interfacing push-button(momentary) switches Used for large number(>8) push-buttons Relies on matrix arrangement.
Arduino Interrupts Paul MacDougal September 8, 2014.
CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
KyungHee Univ. 1-0 문자열 입 · 출력 프로그램 작성 예. KyungHee Univ. 1-1  모니터에 문자열 출력 하는 프로그램 작성  표준 출력 장치에 문자를 출력 하는 함수 함수의 기본형 : void SCI_OutChar(letter)  문자를.
1 4-Integrating Peripherals in Embedded Systems (cont.)
Recursion Examples Fundamentals of CS Case 1: Code /* Recursion: Case 1 */ #include void count (int index); main () { count (0); getchar(); } void count.
Dennis Ritchie 1972 AT & T Bell laboratories (American Telephone and Telegraph) USA 1www.gowreeswar.com.
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)
Digital Inputs Interfacing Keypad
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
// A // --- // F| G |B // --- // E| |C // ---.Dp // D // My LED Functions Scott Nichols.
LHO 22 C and the  The Silicon Labs ISE uses the Keil C51 compiler.  The code size is limiter to 2K  C has replaced PL/M (the original Intel high.
Char ch; ch ‘L’‘X’‘V’‘I’ As in Roman numerals Want to give each a value, n say switch (ch) { case ‘I’:n = 1; break; case ‘V’:n = 5; break; … default:cout.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
Matrix Key Pad Configuration Lecturer: Reza Arjmandi Autumn 2015 Lecture 6: Introduction Matrix KeyPad Configuration.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
CPUMemoryIO-1IO-2 Address BUS Data BUS Control BUS Memory Map IO Map 8bytes 2bytes IO-1 IO-2 A3~A0 D7~D0.
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 실 습실 습 4.
Arduino + Bluetooth TYWu. Connection Arduino + Bluetooth Module.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
전자공학과 유승민 FND 과제. 1. 과제 내용 A~F 까지 십진수로 나타내기 이 진 수이 진 수 십진수 gfedcba A b C d E F
C++ Lesson 1.
디지털 로직 및 CAD 실습 Fundamentals of Logic Design (6e) Charles H. Roth, Jr.
4-Integrating Peripherals in Embedded Systems (cont.)
LESSON 3 IO, Variables and Operators
Reserved Words.
Keypad Source: under under
null, true, and false are also reserved.
הרצאה 08 פרמטרים ל- main קרן כליף.
פרטים נוספים בסילבוס של הקורס
פרטים נוספים בסילבוס של הקורס
Govt. Polytechnic,Dhangar
Variables in C Declaring , Naming, and Using Variables.
Keypad Source: under under
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Keypad Source: under under
Programming Language C Language.
Presentation transcript:

FND, Keypad 사용 계산기 설계 20072413 박민호

계산기 설계 Specification 몫 Keypad, FND(7-Segment) 사용 C기반 설계 음수표현 : LED에 1 출력 곱셈 : 0~9입력 -> 0~81출력 나눗셈 : 나머지 몫

Keypad scheme 계산기 설계

Source code - predefine 계산기 설계 Source code - predefine #include <avr/io.h> #define LED_CS (*(volatile unsigned char *)0x4800) #define KEY_DATA (*(volatile unsigned char *)0x5400) #define KEY_SCAN (*(volatile unsigned char *)0x5800) #define DIG_SELECT (*(volatile unsigned char *)0x7000) #define FND_DATA (*(volatile unsigned char *)0x6C00) #define DIP_SW_CS (*(volatile unsigned char *)0x8000) void Platform_Init(void); void Write_KeyPadData(uint8_t data); uint8_t Read_KeyPadData(void); void KeyPadScan(uint8_t *pdata, uint8_t *presult); void ExtFndSet(uint8_t data); void delay_us(unsigned char time_us); void delay_ms(unsigned int time_ms); void digits_FND(uint8_t data); void calc(uint8_t a, uint8_t b, uint8_t *presult);

계산기 설계 Source code - main int main(void){ Platform_Init(); uint8_t a, b, result; //입력 및 계산 결과 버퍼 uint8_t *pa, *pb, *presult; //입력 및 계산 결과 버퍼 포인터 pa = &a; pb = &b; presult = &result; while(1){ KeyPadScan(pa, presult); //Call by Reference KeyPadScan(pb, presult); //Call by Reference calc(a, b, presult); //계산 결과만 Call by Reference }

Source code - functions 계산기 설계 Source code - functions void Platform_Init(void){ MCUCR = 0x80; } //값을 읽을 행을 선택. 스캔할 Row void Write_KeyPadData(uint8_t data){ KEY_DATA = data; //값을 읽음 uint8_t Read_KeyPadData(void){ return KEY_SCAN; void delay_us(unsigned char time_us){ register unsigned char i; for(i = 0; i < time_us; i++){ asm volatile("PUSH R0"); asm volatile("POP R0"); } void delay_ms(unsigned int time_ms){ register unsigned int i; for(i = 0; i < time_ms; i++){ delay_us(250);

계산기 설계 Source code - fnd value void ExtFndSet(uint8_t data){ switch(data) { case 0: FND_DATA = ~0x3F; //~(0b0011 1111) -> 0b1100 0000 break; case 1: FND_DATA = ~0x06; ... case 9: FND_DATA = ~0x6F; default: //Dot FND_DATA = ~0x80; }

계산기 설계 Source code - keypad 1 void KeyPadScan(uint8_t *pdata, uint8_t *presult){ uint8_t data; while(1){ Write_KeyPadData(0x0E); //1번 Row 스캔 data = Read_KeyPadData(); //각 Column 가져오기 if(!(data&0x01)){ *presult = *pdata = 0x03; while((Read_KeyPadData() & 0x0F) != 0x0F){ digits_FND(*pdata); } break; ...

계산기 설계 Source code - keypad 2 Write_KeyPadData(0x0D); //2번 줄 스캔 ... Write_KeyPadData(0x0B); //3번 줄 스캔 Write_KeyPadData(0x07); //4번 줄 스캔 //아무것도 안누르고 있을 때 이전 입력을 출력 if((Read_KeyPadData() & 0x0F) == 0x0F){ digits_FND(*presult); } } //while문 끝

Source code - fnd output 계산기 설계 Source code - fnd output void digits_FND(uint8_t data){ if((data & 0x7F) >= 0 && (data & 0x7F) < 10){ //절대값이 한 자리수일 때. DIG_SELECT = 0x80; ExtFndSet(data & 0x7F); delay_ms(15); //1의 자리수 출력 및 딜레이 } else if((data & 0x7F) > 9 && (data & 0x7F) < 100){ //절대값이 두 자리수일 때. ExtFndSet((data & 0x7F) % 10); delay_ms(5); //1의 자리수 출력 및 딜레이 DIG_SELECT = 0x40; ExtFndSet((data & 0x7F) / 10); delay_ms(5); //10의 자리수 출력 및 딜레이 else{ //세 자리 이상이거나 에러면 .. 출력 DIG_SELECT = 0xC0; ExtFndSet(data); } //부호 표시 if((data & 0x80) == 0x80) //음수일 때 LED에 1 출력 LED_CS = 0x01; else //양수일 때 LED에 0 출력 LED_CS = 0x00;

Source code - calculation 1 계산기 설계 Source code - calculation 1 void calc(uint8_t a, uint8_t b, uint8_t *presult){ uint8_t operator = ~DIP_SW_CS; //연산자 저장 switch(operator){ case 0: // + : plus *presult = a + b; break; case 1: // - : minus if(a >= b) //결과 값이 양수일 때 계산 *presult = (a - b); else //결과 값이 음수일 때 계산 *presult = (b - a) | 0x80; ...

Source code - calculation 2 계산기 설계 Source code - calculation 2 case 2: // * : multiply *presult = (a * b); if(*presult > 0x7F) *presult = 0x7F; //0x7F(127)를 넘으면 에러 break; case 3: // / : divide if(b == 0) //divider is 0 - error. the error output is the dots *presult = 0x7F; else *presult = ((a / b) + (((a % b)<<3) + ((a % b)<<1))); default: //operator exception }

Source code - demonstration 계산기 설계 Source code - demonstration

계산기 설계 Thank you Q&A