5. Serial Communication 충북인력개발원 전자과 공학박사 강원찬.

Slides:



Advertisements
Similar presentations
Review: Interrupts & Timers
Advertisements

C Examples 1.
Serial I/O - Programmable Communication Interface
Better Debugging of Embedded via a Debug Port ECE152.
Better Debugging of Embedded via a Debug Port ECE152.
Spring EE 316 Computer Engineering Junior Lab Serial Ports.
USART and Asynchrono us Communica tion The USART is used for synchronous and asynchronous serial communication. USART = Universal Synchronous/Asynchronous.
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
An Embedded C Program 1 Mainly from textbook: Embedded C Programming and the Atmel AVR 2 nd Edition Barnett, Cox and O’Cull.
External & internal Interrupts. Interrupt Sources There are 21 different interrupts and each one has its own vector located in a predefined location at.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
EEE305 Microcontroller Systems Lecture 7: Embedded C using PIC microcontrollers Serial i/o with the XC8 Teaching resources are at
RS-232 Introduction H.C. Tsou 10/31/2003. BENQ Confidential (yyyy/mm/dd)  2003, BENQ Corporation.
University of Tehran 1 Interface Design Serial Communications Omid Fatemi.
EE138 Serial Communication
1 © 2004, Cisco Systems, Inc. All rights reserved. Chapter 5 WANs and Routers/ Introduction to Routers.
Serial Communication ETEC 6416.
Serial Communication Lab 12 Module M21.1. Asynchronous Serial I/O ASCII code 54H = (“T”) sent with odd parity.
328eForth for Arduino Uno C. H. Ting February 16, 2012 SVFIG.
Embedded Systems Programming 1 ETEE 3285 Topic HW3: Coding, Compiling, Simulating.
Serial Port I/O Serial port sends and receives data one bit at a time. Serial communication devices are divided into: Data Communications Equipment (DCE),
1 4-Integrating Peripherals in Embedded Systems (cont.)
Communication Systems I. How can information flow from point A to point B?
NAND boot over I2C example
Microprocessors 2 lesson Subjects lesson 7 Planning Interrupts Serial communication /USART Questions.
1 Lab 1: Introduction. 2 Configure ATMEL AVR Starter Kit 500 (STK500), a prototyping/development board for Lab1. ATmega16 ( V) is the chip used.
* Bluetooth Evaluation Kit * MD-5XR : Bluetooth DSP Module - BC05 Multi-Media chip * Supported Profiles. - HFP (Handsfree Profile) - A2DP(Advanced Audio.
LCD Interfacing.
Ch.2 – Introduction to Routers
Atmel Atmega128 Overview ALU Particulars RISC Architecture 133, Mostly single cycle instructions 2 Address instructions (opcode, Rs, Rd, offset) 32x8 Register.
AVR Programming: Interrupts September 17, What are interrupts? An asynchronous signal indicating the need for an event to be handled A synchronous.
Serial Communication Interface Ta Kim Nicholas Earnhart Razid Ahmad ME 6405 – Fall 2008 November 6, 2008.
CE-2810 Dr. Mark L. Hornick 1 Using the USART Configuration and Programming.
Asynchronous Serial I/O Unit 12 - Part 1. SCI Registers – Channel 0 SCI0BDH – SCI Baud Rate Register High Byte SCI0BDL – SCI Baud Rate Register Low.
Interrupt. incoming Lab. Interrupt an asynchronous signal indicating the need for attention hardware interrupt/software interrupt call “interrupt service.
11. Temperature & Time 제어 충북인력개발원 전자과 공학박사 강원찬.
Serial Communications Interface Module Slide #1 of 19 MC68HC908GP20 Training PURPOSE -To explain how to configure and use the Serial Communications Interface.
충북인력개발원 전자과 공학박사 강원찬 3. Timer & Counter &PWM. uP AVR (Atmega128) PWM1=OC1A(PB5) PWM2=OC1B(PB6) T0=T1(PD6) T1=T2(PD7)
1 Pertemuan 2 Routers. Discussion Topics Introduction to WANs Router physical characteristics Router external connections Management port connections.
1 Pertemuan 12 Cabeling WANs. Discussion Topics WAN physical layer WAN serial connections Routers and serial connections Routers and ISDN BRI connections.
CE-2810 Dr. Mark L. Hornick 1 Serial Communications Sending and receiving data between devices.
Prestige NAND Flash DOWNLOAD. Prepare ITEM. 1.PC - Run Tftpd32 program. (Tftpd setup.exe install ) 2. Download DVR B/D 3. Download Serial B/D 4.
Chap.6.3 UART.
GUIDED BY PROFFESOR NILESH DESAI GROUP NO:-8 CHANDRASHIKHA SINGH( ) KURUP SHUBHAM VALSALAN( ) SAURAV SHUBHAM( )
Vishwakarma government engineering college Prepare by. Hardik Jolapara( ) LCD Interfacing with ATmega16.
NAM S.B MDLAB. Electronic Engineering, Kangwon National University 1.
8251 USART.
Communication Systems I CPE 313: Micro Processors and Interfacing.
Interfacing of Input/Output devices with AVR Microcontroller Enrolment No. : Name of the student: SOMAIYA ISHA.
BASICS OF SERIAL COMMUNICATIONS BIRLA VISHWKARMA MAHAVIDYALAYA ELECTRONICS & TELECOMMUNICATION DEPARTMENT PRESENTING BY: ABHISHEK SINGH AMANDEEP.
충북인력개발원 전자과 공학박사 강원찬 2. Interrupt & LCD. uP AVR (Atmega128) - 2 -
1 Lab 4: D/A Converter Lab 4: D/A Converter This is a simple resistive network for a D/A converter Port 1, Port 0 are digital inputs ==> 00 (minimum),
INTERFACING KEYBOARD WITH ATMEGA32 ELECTRONICS & COMMUNICATION TITLE.
Lecture 15. Modem Controller Register 4310 DTR 0 = Polling Operator 1 = Interrupts Enabled RTS 1 =Self Test 0 =Normal.
Jeremy Sandoval University of Washington May 14, 2013
Lab 7 Basic 1: Game of Memory
LCD Interfacing using Atmega 32
CS-401 Computer Architecture & Assembly Language Programming
Lecture # 13.
Homework Reading (linked from my web page) Machine Projects Labs
SERIAL PORT PROGRAMMING
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 6: Serial Communication Prof. Chung-Ta King Department of Computer Science National.
Session 3,4.
UART Protocol Chapter 11 Sepehr Naimi
Lecturer: Reza Arjmandi Autumn 2015
Zack and A.C. Sensor Report.
Configuration and Programming
AVR Programming in C Chapter 7
Serial Communication 19th Han Seung Uk.
AVR UART The UART, or Universal Asynchronous Receiver Transmitter, provides hardware support for a serial port on AVR processors Signaling is compatible.
Presentation transcript:

5. Serial Communication 충북인력개발원 전자과 공학박사 강원찬

PORTA=J30(S/W &LED) PORTC=J19(LCD) USB=(Serial) [SW49 DIP=6,8 ON] ** USB 2.0 TO RS232 Cable 프로그램설치

PC-> Hyper Terminal 설치 [시작]-[프로그램]-[보조프로그램]-[통신]-[하이퍼터미널]

COM 5, 9600bps 8bit, no parity 하드웨어 흐름제어 사용않음 제어판에서 포트번호 확인

새 프로젝트 생성(File->New)

시리얼통신 #include <mega128.h> #include <stdio.h> // 자동으로 추가된 부분 void main(void) { PORTA=0x00; DDRA=0x00; // USART0 initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART0 Receiver: On // USART0 Transmitter: On // USART0 Mode: Asynchronous // USART0 Baud rate: 9600 UCSR0A=0x00; UCSR0B=0x18; UCSR0C=0x06; UBRR0H=0x00; UBRR0L=0x2F; while (1) { }; } // USART0 initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART0 Receiver: Off // USART0 Transmitter: On // USART0 Mode: Asynchronous // USART0 Baud rate: 19200 UCSR0A=0x00; UCSR0B=0x08; UCSR0C=0x06; UBRR0H=0x00; UBRR0L=0x33;

예제1 #include <mega128.h> #include <stdio.h> void main(void) { int i=0; PORTA=0x00; DDRA=0x00; // Communication Parameters: 8 Data, 1 Stop, No Parity // USART0 Baud rate: 9600 UCSR0A=0x00; UCSR0B=0x18; UCSR0C=0x06; UBRR0H=0x00; UBRR0L=0x2F; printf("Connect sucess!!\n\r"); while (1) { if (PINA.0==0) // S/W1을 누르면 PC로 데이터 전송 { printf("Command[%3d]\n\r", i++) ; } else { scanf("%c",&temp); printf("%c->ok",temp); }; 예제1

#include <mega128. h> #include <stdio #include <mega128.h> #include <stdio.h> char flash TITLE_LINE[] = "Chung-buk HRDI of KorCham"; char print_back(void) { char cmd,c[5]; int ch,i; while((ch=getchar()) != '\r') /*한문자를 입력받고 줄바꿈이 아니면 실행한다.*/ { c[i++] = ch; putchar(ch); } cmd = c[i-1]; return(cmd); } void main(void) { // USART0 initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART0 Baud rate: 9600 UCSR0A=0x00; UCSR0B=0x18; UCSR0C=0x06; UBRR0H=0x00; UBRR0L=0x33; //67(16M) // Global enable interrupts #asm("sei") putsf(TITLE_LINE); printf("\n\rPress Keyboard\n\r"); while (1) { char cmd; cmd = print_back(); }

연습문제 1) 다음과 같이 PC화면을 나타내시오. 2) Switch 문을 사용하여 다음의 기능을 수행 ========================= Wel come to My AVR World Press Any Key(a, s, w, z) 2) Switch 문을 사용하여 다음의 기능을 수행 a: LED 출력 (0xfe), 처리결과 PC에 전송 s: LED 출력 (0xf0), 처리결과 PC에 전송 w: LED 출력 (0x0f), 처리결과 PC에 전송 z: LED 출력 (0xcc), 처리결과 PC에 전송 기타 : LED 출력 (0x00), 에러 PC에 전송

-끝-

#include <mega128. h> #include <stdio. h> #include <lcd #include <mega128.h> #include <stdio.h>      #include <lcd.h> char flash TITLE_LINE[] = "Chung-buk HRDI of KorCham";   #asm    .equ __lcd_port=0x15 ;PORTC #endasm  unsigned temp; void main(void) { int i=0;  PORTA=0x00;  DDRA=0x00; // Communication Parameters: 8 Data, 1 Stop, No Parity // USART0 Baud rate: 9600  UCSR0A=0x00;  UCSR0B=0x18;  UCSR0C=0x06;  UBRR0H=0x00;  UBRR0L=0x2F; 

 lcd_init(16);     lcd_gotoxy(0,0);  lcd_putsf("hello serial\n");           printf("Connect  sucess!!\n\r"); while (1)       {      if (PINA.0==0) // S/W1을 누르면 PC로 데이터 전송        { printf("Command[%3d]\n\r", i++) ;                 PORTB=0xcc;                         }   else       { scanf("%c",&temp);          printf("%c->ok\t",temp);           }       }; }