SlideShare a Scribd company logo
1 of 17
X[Deca] AVR study
Konkuk University. Department of Electronic Engineering
v0.1 by08기 김정목
v0.2 by11기 정성호
Page  2
2
Contents
USART
Contents
1 ASCII
Page  3
ASCII
ASCII란?
- American Standard Code for Information Interchange
- 미국의 정보교환에 대한 표준 코드
- 8bit = Data 7bit + Parity 1bit
- 코드화된 문자 = 제어문자 + 도형문자(알파벳, 숫자 등)
Page  4
USART
1. USART
- Universal Synchronous and Asynchronous serial Receiver and Transmitter
- 범용 동기 / 비동기 직렬 송수신장치
1) 직렬(Serial) 통신
- 디바이스 간의 데이터 흐름이 한 주기 안에 하나씩 전송되는 방식
- 구현하기 용이 / 병렬통신에 비해 느림
2) 병렬(Parallel) 통신
- 디바이스 간의 데이터 흐름이 한 주기 안에 여러 개 전송되는 방식
- 전송속도 빠름 / 가격이 높음
3) 동기식(Synchronous) 통신
- 송신과 수신 상대가 직접 시간을 일치시켜서 데이터를 송수신 하는 방식
4) 비동기식(Asynchronous) 통신
- 송수신간에 신호를 주고 받으며 작업을 수행하는 방식
- 시작/정지 방식과 단계적 시작/정지 방식이 있음
10010
1
0
0
1
0
Page  5
USART
USART in Atmega128
1. Overview
- 외부 장치와 데이터를 주고 받을(통신) 수 있게 해줌
- 2개의 USART 제공 : USART0 / USART1
2. Frame format
1) IDLE – No transfer on the communication line / always high
2) St – 1 Start bit / always low
3) Data bit – 5, 6, 7, 8, or 9 data bit
4) P – no, even, odd parity bit
5) Sp – 1 or 2 stop bit / always high
Page  6
USART
Page  7
USART _ Register Description
1.UDRn – USARTn I/O Data Register
- RXBn : Receive Data Buffer Register
- TXBn : Transmit Data Buffer Register
- TXBn / RXBn는 같은 I/O address UDRn 공유
- The transmit buffer(TxBn)은 UCSRnA Register의 UDREn flag가
set -> Data write
clear -> Data ignore
Page  8
2. UCSRnA – USARTn Control and Status Register A
1)RXCn – USARTn Receive Complete
-Receive buffer에 읽지 않은 data가 있으면 1 / 없으면 0
2) TXCN – USARTn Transmit Complete
-Shift Register의 data가 모두 전송되고 UDRn에 새로운 data가 쓰여지지 않으면 0 / 있으면 1
3) UDREn – USARTn Data Register Empty
-UEREn이 1이면 buffer가 비어 있음 / 0이면 buffer가 비어 있지 않음
4) FEn – Frame Error
- 프레임 에러가 발생했을 때 1로 설정.
5) DORn – Data Overrun
- 데이터 오버런(Data OverRun)이 발생했을 때 1로 설정. 데이터 오버런은 수신 버퍼가 모두 찼을 때 발생.
6) UPEn – Parity Error
- 수신 버퍼의 데이터에 패리티 에러(Parity Error)가 발생했을 때 1로 설정.
7) U2Xn – Double the USART Transmission Speed
- 비동기 동작에서만 영향을 미친다. 동기 동작에서는 0으로 설정해야 한다. 보레이트 분주기의 제수(除數)를
16에서 8로 줄여 전송 속도를 2배로 높인다.
8) MPCMn – Multi-Processor Communication Mode
- 멀티프로세서 통신 모드를 enable 한다.
USART _ Register Description
Page  9
3. UCSRnB – USARTn Control and Status Register B
1)RXCIEn
- 수신완료 인터럽트 enable
2) TXCIEn
- 송신완료 인터럽트 enable
3) UDRIEn
- 송신 데이터 레지스터 준비완료 인터럽트 enable
4) RXENn – Receiver Enable
- 수신부 enable
5) TXENn – Transmitter Enable
- 송신부 enable
6) UCSZn2 – Character Size
- UCSRnC에 있는 UCSZn1:0 비트와 합쳐져 송수신에 사용될 데이터 비트의 수를 설정.
7) RXB8n
- 시리얼 프레임이 9-data bits일 경우 수신된 데이터의 9번째 bit를 가리킴.
8) TXB8n
- 시리얼 프레임이 9-data bits일 경우 송신될 데이터의 9번째 bit를 가리킴.
USART _ Register Description
Page  10
4. UCSRnC – USARTn Control and Status Register C
1) Reserved bit
- 미래 사용을 위해서 비워둔 bit, clear(0)으로 해둠
2) UMSELn – USARTn Mode Select
- Asynchronous / Synchronous 선택
3) UPMn[1:0] – Parity Mode
- Parity mode 설정
USART _ Register Description
Page  11
4. UCSRnC – USARTn Control and Status Register C
4) USBSn – Stop Bit Select
- Stop bit 개수 설정
5) UCSZn[1:0] – Character size
- UCSRnB의 UCSZn2와 함께 사용되어 Data bit의 수(character size) 결정
USART _ Register Description
Page  12
5. UBRRnL / UBRRnH – USARTn Baud Rate Register
- Datasheet 195~198p / Table82~Table85 참고
USART _ Register Description
Page  13
USART _ 실습1
1. 실습 1-1
-키보드로 입력된 문자를 Atmega에 전달하여
-다시 모니터로 출력하는 프로그램을 작성한다.
2. 실습 1-2
-함수형태로 만들어 본다.
16bit Register 읽기/쓰기 주의점
읽기 – 하위->상위 순서
쓰기 – 상위->하위 순서
Asynchronous
No parity bit
1 stop bit
8-bit data bit
Baud rate :115200(bps)
Page  14
USART _ 실습1
Page  15
USART _ 실습2
1. 실습 2-1
-키보드를 이용해서 문자를 입력 받는다.
-이때 입력 받는 문자가 대문자이면 소문자로 / 소문자이면 대문자로 변환하여 모니터로 출력한다.
-알파벳이 아닌 다른 문자일 경우 @를 출력한다.
2. 실습 2-2
-처음에 1번 LED를 킨다.
-키보드의 ‘u’ 또는 ‘U’를 누르면 LED가 하나씩 올라가면서 켜진다.
• 8번 LED에서는 1번으로 간다.
-키보드의 ‘d’ 또는 ‘D’를 누르면 LED가 하나씩 아래로 내려가며 켜진다.
• 1번 LED에서는 8번으로 간다.
Page  16
USART _ 실습2
Page  17
USART _ 실습2

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

03. usart

  • 1. X[Deca] AVR study Konkuk University. Department of Electronic Engineering v0.1 by08기 김정목 v0.2 by11기 정성호
  • 3. Page  3 ASCII ASCII란? - American Standard Code for Information Interchange - 미국의 정보교환에 대한 표준 코드 - 8bit = Data 7bit + Parity 1bit - 코드화된 문자 = 제어문자 + 도형문자(알파벳, 숫자 등)
  • 4. Page  4 USART 1. USART - Universal Synchronous and Asynchronous serial Receiver and Transmitter - 범용 동기 / 비동기 직렬 송수신장치 1) 직렬(Serial) 통신 - 디바이스 간의 데이터 흐름이 한 주기 안에 하나씩 전송되는 방식 - 구현하기 용이 / 병렬통신에 비해 느림 2) 병렬(Parallel) 통신 - 디바이스 간의 데이터 흐름이 한 주기 안에 여러 개 전송되는 방식 - 전송속도 빠름 / 가격이 높음 3) 동기식(Synchronous) 통신 - 송신과 수신 상대가 직접 시간을 일치시켜서 데이터를 송수신 하는 방식 4) 비동기식(Asynchronous) 통신 - 송수신간에 신호를 주고 받으며 작업을 수행하는 방식 - 시작/정지 방식과 단계적 시작/정지 방식이 있음 10010 1 0 0 1 0
  • 5. Page  5 USART USART in Atmega128 1. Overview - 외부 장치와 데이터를 주고 받을(통신) 수 있게 해줌 - 2개의 USART 제공 : USART0 / USART1 2. Frame format 1) IDLE – No transfer on the communication line / always high 2) St – 1 Start bit / always low 3) Data bit – 5, 6, 7, 8, or 9 data bit 4) P – no, even, odd parity bit 5) Sp – 1 or 2 stop bit / always high
  • 7. Page  7 USART _ Register Description 1.UDRn – USARTn I/O Data Register - RXBn : Receive Data Buffer Register - TXBn : Transmit Data Buffer Register - TXBn / RXBn는 같은 I/O address UDRn 공유 - The transmit buffer(TxBn)은 UCSRnA Register의 UDREn flag가 set -> Data write clear -> Data ignore
  • 8. Page  8 2. UCSRnA – USARTn Control and Status Register A 1)RXCn – USARTn Receive Complete -Receive buffer에 읽지 않은 data가 있으면 1 / 없으면 0 2) TXCN – USARTn Transmit Complete -Shift Register의 data가 모두 전송되고 UDRn에 새로운 data가 쓰여지지 않으면 0 / 있으면 1 3) UDREn – USARTn Data Register Empty -UEREn이 1이면 buffer가 비어 있음 / 0이면 buffer가 비어 있지 않음 4) FEn – Frame Error - 프레임 에러가 발생했을 때 1로 설정. 5) DORn – Data Overrun - 데이터 오버런(Data OverRun)이 발생했을 때 1로 설정. 데이터 오버런은 수신 버퍼가 모두 찼을 때 발생. 6) UPEn – Parity Error - 수신 버퍼의 데이터에 패리티 에러(Parity Error)가 발생했을 때 1로 설정. 7) U2Xn – Double the USART Transmission Speed - 비동기 동작에서만 영향을 미친다. 동기 동작에서는 0으로 설정해야 한다. 보레이트 분주기의 제수(除數)를 16에서 8로 줄여 전송 속도를 2배로 높인다. 8) MPCMn – Multi-Processor Communication Mode - 멀티프로세서 통신 모드를 enable 한다. USART _ Register Description
  • 9. Page  9 3. UCSRnB – USARTn Control and Status Register B 1)RXCIEn - 수신완료 인터럽트 enable 2) TXCIEn - 송신완료 인터럽트 enable 3) UDRIEn - 송신 데이터 레지스터 준비완료 인터럽트 enable 4) RXENn – Receiver Enable - 수신부 enable 5) TXENn – Transmitter Enable - 송신부 enable 6) UCSZn2 – Character Size - UCSRnC에 있는 UCSZn1:0 비트와 합쳐져 송수신에 사용될 데이터 비트의 수를 설정. 7) RXB8n - 시리얼 프레임이 9-data bits일 경우 수신된 데이터의 9번째 bit를 가리킴. 8) TXB8n - 시리얼 프레임이 9-data bits일 경우 송신될 데이터의 9번째 bit를 가리킴. USART _ Register Description
  • 10. Page  10 4. UCSRnC – USARTn Control and Status Register C 1) Reserved bit - 미래 사용을 위해서 비워둔 bit, clear(0)으로 해둠 2) UMSELn – USARTn Mode Select - Asynchronous / Synchronous 선택 3) UPMn[1:0] – Parity Mode - Parity mode 설정 USART _ Register Description
  • 11. Page  11 4. UCSRnC – USARTn Control and Status Register C 4) USBSn – Stop Bit Select - Stop bit 개수 설정 5) UCSZn[1:0] – Character size - UCSRnB의 UCSZn2와 함께 사용되어 Data bit의 수(character size) 결정 USART _ Register Description
  • 12. Page  12 5. UBRRnL / UBRRnH – USARTn Baud Rate Register - Datasheet 195~198p / Table82~Table85 참고 USART _ Register Description
  • 13. Page  13 USART _ 실습1 1. 실습 1-1 -키보드로 입력된 문자를 Atmega에 전달하여 -다시 모니터로 출력하는 프로그램을 작성한다. 2. 실습 1-2 -함수형태로 만들어 본다. 16bit Register 읽기/쓰기 주의점 읽기 – 하위->상위 순서 쓰기 – 상위->하위 순서 Asynchronous No parity bit 1 stop bit 8-bit data bit Baud rate :115200(bps)
  • 14. Page  14 USART _ 실습1
  • 15. Page  15 USART _ 실습2 1. 실습 2-1 -키보드를 이용해서 문자를 입력 받는다. -이때 입력 받는 문자가 대문자이면 소문자로 / 소문자이면 대문자로 변환하여 모니터로 출력한다. -알파벳이 아닌 다른 문자일 경우 @를 출력한다. 2. 실습 2-2 -처음에 1번 LED를 킨다. -키보드의 ‘u’ 또는 ‘U’를 누르면 LED가 하나씩 올라가면서 켜진다. • 8번 LED에서는 1번으로 간다. -키보드의 ‘d’ 또는 ‘D’를 누르면 LED가 하나씩 아래로 내려가며 켜진다. • 1번 LED에서는 8번으로 간다.
  • 16. Page  16 USART _ 실습2
  • 17. Page  17 USART _ 실습2

Editor's Notes

  1. 1