SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
임베디드임베디드 마이크로프로세서마이크로프로세서
프로그래밍프로그래밍 실전실전
제작제작 :: 네네 로로 테테 크크
강의강의 :: 김김 종종 형형
--22--20062006--0404--0808
Embedded AVR ProgrammingEmbedded AVR Programming
ATMEGA128ATMEGA128의의 실전실전 ⅡⅡ
1. RTC란
2. DS1302를 이용한 RTC 실습
--33--20062006--0404--0808
Embedded AVR ProgrammingEmbedded AVR Programming
1-1 RTC (Real Time Clock)이란?
⊙ 실시간 시계. 전원 공급이 안 되어도 현재의 시간을 지키는 시계
⊙ DS1302란?
- Trickle charge RTC (세류 충전 계시 칩, 혹은 트리클 충전 계시 칩)
- Trickle => 물방울, 졸졸 흐르는 시내물.
적은 전류로 충전(==> 동작)하는 RTC라고 생각하면 됨
- DS1302는 내부에 여러 개의 데이터 영역을 가지고 있으며, 각각의 영역마다 초, 분, 시, 년,
월, 일 등의 데이터를 기록하고, 자동으로 갱신시켜 줌. 유저는 단지 이 데이터를 읽어와 사용
--44--20062006--0404--0808
Embedded AVR ProgrammingEmbedded AVR Programming
1-2 DS1302를 이용한 RTC
⊙ 핀 정리
1 : VCC2 : 메인 전원용 VCC와 연결
2, 3 : X1, X2 : 32768 크리스털과 연결
4 : GND : 전원 그라운드
5 : #RST : 칩 선택용이니 CS(chip enable)
6 : I/O : 시리얼 데이터를 주고 받는 포트
7 : SCLK : 시리얼 클럭. 데이터를 주고 받을 때 사용하는 클럭
8 : VCC1 : 백업용 배터리를 연결
--55--20062006--0404--0808
Embedded AVR ProgrammingEmbedded AVR Programming
1-2 DS1302를 이용한 RTC
⊙ 회로도
U5
DS1302SN/SOIC
X1
2
X2
3
GND
4
RST
5
I/O
6
SCLK
7 VCC2
1
VCC1
8
X1
32.768KHz
BT1
TL5101
JP12
HEADER/2X3
1 2
3 4
5 6
RTC.BAT
#BIT.RST
#BIT.SLK
BIT.IO
VCC
I2C/RTC
VCC.BAT
D1
1N5819
D2
1N5819
VCC
--66--20062006--0404--0808
Embedded AVR ProgrammingEmbedded AVR Programming
1-2 DS1302를 이용한 RTC
⊙ DS1302의 내부 데이터 영역도
--77--20062006--0404--0808
Embedded AVR ProgrammingEmbedded AVR Programming
1-2 DS1302를 이용한 RTC
⊙ 명령 및 어드레스, 데이터 송수신 순서
--88--20062006--0404--0808
Embedded AVR ProgrammingEmbedded AVR Programming
1-3 DS1302를 이용한 RTC 실습 1
☞ DS1302를 이용한 Real Time Clock 를 LCD로 표시하는 프로그램
// timer 0 overflow ISR
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
TCNT0 = 6; // reload for 1ms ticks
if(++timecount == 500) // 500ms 마다 업데이트
{
tick1flag = 1;
timecount = 0; // clear for next 500ms
}
}
void main(void)
{
unsigned char h,m,s,i;
MCUCR=0xc0; // am_lcd함수 사용시
//Port D
PORTD = 0xff;
DDRD = 0xff;
TCNT0 = 0x00; // reset TCNT0
TCCR0 = 0x04; // count with cpu clock/64 (64/16MHz=4ms)
TIMSK = 0x01; // enable TCNT0 overflow
#include <mega128.h>
#include <stdio.h>
#include <delay.h>
#include "am_lcd.h"
#include "am_lcd.c"
// DS1302 Real Time Clock functions
#asm
.equ __ds1302_port=0x12 ;PORTD
.equ __ds1302_io=4
.equ __ds1302_sclk=5
.equ __ds1302_rst=2
#endasm
#include <ds1302.h>
char rtc_buf[16]; // lcd display temp buffer
char lcd_state;
bit tick1flag=0;
unsigned int timecount = 0; // global time counter
--99--20062006--0404--0808
Embedded AVR ProgrammingEmbedded AVR Programming
1-3 DS1302를 이용한 RTC 실습 1
☞ DS1302를 이용한 Real Time Clock 를 LCD로 표시하는 프로그램
while(1)
{
if (tick1flag) // 0.5초마다 업데이트
{
if(i==0)
{
i=1;
lcd_state = 43; // "X"를 표시
}
else
{
i=0;
lcd_state = 120; // "+"를 표시
}
lcd_clear();
Gotoxy(0,0);
_lcd_str(" M128 RTC TEST1 ");
sprintf(rtc_buf,"%c TIME %2d:%2d:%2d",lcd_state
,h,m,s,lcd_state);
Gotoxy(0,1); // LCD 둘째 줄 왼쪽 처음으로 이동
lcd_str(rtc_buf); // LCD에 tpbuf 표시
tick1flag = 0;
}
rtc_get_time(&h,&m,&s); // DS1302에서 시간데이터 얻기
}
}
#asm("sei");
// DS1302 Real Time Clock initialization
// Trickle charger: On
// Trickle charge resistor: None
// Trickle charge diode(s): 1
rtc_init(1,1,0);
/* initialize the LCD for 2 lines & 16 columns */
lcd_init();
Gotoxy(0,0);
_lcd_str(" ::AVRMall::");
Gotoxy(0,1);
_lcd_str("Real Time Clock 1");
rtc_set_time(12,0,0);
//rtc_set_date(15,6,4);
delay_ms(2000);

Weitere ähnliche Inhalte

Andere mochten auch

2013 mcu( 마이크로컨트롤러 ) 수업자료 2
2013 mcu( 마이크로컨트롤러 ) 수업자료 22013 mcu( 마이크로컨트롤러 ) 수업자료 2
2013 mcu( 마이크로컨트롤러 ) 수업자료 2진우 김
 
Types of Production and Manufacturing
Types of Production and ManufacturingTypes of Production and Manufacturing
Types of Production and ManufacturingCasey Robertson
 
Writing Code That Lasts - Joomla!Dagen 2015
Writing Code That Lasts - Joomla!Dagen 2015Writing Code That Lasts - Joomla!Dagen 2015
Writing Code That Lasts - Joomla!Dagen 2015Rafael Dohms
 
Appraiser : How Airbnb Generates Complex Models in Spark for Demand Prediction
Appraiser : How Airbnb Generates Complex Models in Spark for Demand PredictionAppraiser : How Airbnb Generates Complex Models in Spark for Demand Prediction
Appraiser : How Airbnb Generates Complex Models in Spark for Demand PredictionYang Li Hector Yee
 
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocks
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocksTop Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocks
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocksZeroTurnaround
 
3장 라즈베리 파이와 gpio
3장 라즈베리 파이와 gpio3장 라즈베리 파이와 gpio
3장 라즈베리 파이와 gpioYoung Jin Suh
 
I want to be an efficient developper. Mix-IT version
I want to be an efficient developper. Mix-IT versionI want to be an efficient developper. Mix-IT version
I want to be an efficient developper. Mix-IT versionQuentin Adam
 
How to build a Java Web App in the Cloud
How to build a Java Web App in the CloudHow to build a Java Web App in the Cloud
How to build a Java Web App in the CloudWSO2
 
Programming != Writing Code
Programming != Writing CodeProgramming != Writing Code
Programming != Writing CodeGustavo Cunha
 
Building a Successful Organization By Mastering Failure
Building a Successful Organization By Mastering FailureBuilding a Successful Organization By Mastering Failure
Building a Successful Organization By Mastering Failurejgoulah
 

Andere mochten auch (15)

Avr lecture4
Avr lecture4Avr lecture4
Avr lecture4
 
Avr lecture7
Avr lecture7Avr lecture7
Avr lecture7
 
2013 mcu( 마이크로컨트롤러 ) 수업자료 2
2013 mcu( 마이크로컨트롤러 ) 수업자료 22013 mcu( 마이크로컨트롤러 ) 수업자료 2
2013 mcu( 마이크로컨트롤러 ) 수업자료 2
 
Types of Production and Manufacturing
Types of Production and ManufacturingTypes of Production and Manufacturing
Types of Production and Manufacturing
 
Writing Code That Lasts - Joomla!Dagen 2015
Writing Code That Lasts - Joomla!Dagen 2015Writing Code That Lasts - Joomla!Dagen 2015
Writing Code That Lasts - Joomla!Dagen 2015
 
Appraiser : How Airbnb Generates Complex Models in Spark for Demand Prediction
Appraiser : How Airbnb Generates Complex Models in Spark for Demand PredictionAppraiser : How Airbnb Generates Complex Models in Spark for Demand Prediction
Appraiser : How Airbnb Generates Complex Models in Spark for Demand Prediction
 
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocks
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocksTop Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocks
Top Reasons Why Java Rocks (report preview) - http:0t.ee/java-rocks
 
3장 라즈베리 파이와 gpio
3장 라즈베리 파이와 gpio3장 라즈베리 파이와 gpio
3장 라즈베리 파이와 gpio
 
I want to be an efficient developper. Mix-IT version
I want to be an efficient developper. Mix-IT versionI want to be an efficient developper. Mix-IT version
I want to be an efficient developper. Mix-IT version
 
How to build a Java Web App in the Cloud
How to build a Java Web App in the CloudHow to build a Java Web App in the Cloud
How to build a Java Web App in the Cloud
 
Virtual Gets Real!
Virtual Gets Real! Virtual Gets Real!
Virtual Gets Real!
 
How Change Happens
How Change HappensHow Change Happens
How Change Happens
 
Programming != Writing Code
Programming != Writing CodeProgramming != Writing Code
Programming != Writing Code
 
The Technological Singularity
The Technological SingularityThe Technological Singularity
The Technological Singularity
 
Building a Successful Organization By Mastering Failure
Building a Successful Organization By Mastering FailureBuilding a Successful Organization By Mastering Failure
Building a Successful Organization By Mastering Failure
 

Ähnlich wie Avr lecture8

Maze통신교육 i2c
Maze통신교육   i2cMaze통신교육   i2c
Maze통신교육 i2cgeonhee kim
 
Remote-debugging-based-on-notrace32-20130619-1900
Remote-debugging-based-on-notrace32-20130619-1900Remote-debugging-based-on-notrace32-20130619-1900
Remote-debugging-based-on-notrace32-20130619-1900Samsung Electronics
 
TestBCD2016-1(Answer)
TestBCD2016-1(Answer)TestBCD2016-1(Answer)
TestBCD2016-1(Answer)Yong Heui Cho
 
아두이노 2015-2 한동대학교 공학설계입문
아두이노 2015-2 한동대학교 공학설계입문아두이노 2015-2 한동대학교 공학설계입문
아두이노 2015-2 한동대학교 공학설계입문Sangjun Han
 
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술Kyuho Kim
 
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.chcbaram
 
Cubietruck 리눅스 이미지 설치
Cubietruck 리눅스 이미지 설치Cubietruck 리눅스 이미지 설치
Cubietruck 리눅스 이미지 설치ymtech
 
[2] 아두이노 활용 실습
[2] 아두이노 활용 실습[2] 아두이노 활용 실습
[2] 아두이노 활용 실습Chiwon Song
 
Wiznet Academy - WizFi250 기초교육 및 실습
Wiznet Academy - WizFi250 기초교육 및 실습Wiznet Academy - WizFi250 기초교육 및 실습
Wiznet Academy - WizFi250 기초교육 및 실습Steve Kim
 
02. led switch
02. led switch02. led switch
02. led switch성호 정
 
Interrupt @atmega
Interrupt @atmegaInterrupt @atmega
Interrupt @atmegamanintroll
 
Interrupt @atmega
Interrupt @atmegaInterrupt @atmega
Interrupt @atmegamanintroll
 
Tips and experience of DX12 Engine development .
Tips and experience of DX12 Engine development .Tips and experience of DX12 Engine development .
Tips and experience of DX12 Engine development .YEONG-CHEON YOU
 
TestBCD2017-1(answer)
TestBCD2017-1(answer)TestBCD2017-1(answer)
TestBCD2017-1(answer)Yong Heui Cho
 
라즈베리파이 Circulus API 가이드
라즈베리파이 Circulus API 가이드라즈베리파이 Circulus API 가이드
라즈베리파이 Circulus API 가이드Circulus
 
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)내훈 정
 
Let's geek! (1)
Let's geek! (1) Let's geek! (1)
Let's geek! (1) nerdsday
 
김성윤 - 우분투로 슈퍼컴 만들기 (2011Y03M26D)
김성윤 - 우분투로 슈퍼컴 만들기 (2011Y03M26D)김성윤 - 우분투로 슈퍼컴 만들기 (2011Y03M26D)
김성윤 - 우분투로 슈퍼컴 만들기 (2011Y03M26D)Ubuntu Korea Community
 
TestBCD2015-1(Answer)
TestBCD2015-1(Answer)TestBCD2015-1(Answer)
TestBCD2015-1(Answer)Yong Heui Cho
 
Mikrotic CCR1036 라우팅 설정
Mikrotic CCR1036 라우팅 설정Mikrotic CCR1036 라우팅 설정
Mikrotic CCR1036 라우팅 설정ymtech
 

Ähnlich wie Avr lecture8 (20)

Maze통신교육 i2c
Maze통신교육   i2cMaze통신교육   i2c
Maze통신교육 i2c
 
Remote-debugging-based-on-notrace32-20130619-1900
Remote-debugging-based-on-notrace32-20130619-1900Remote-debugging-based-on-notrace32-20130619-1900
Remote-debugging-based-on-notrace32-20130619-1900
 
TestBCD2016-1(Answer)
TestBCD2016-1(Answer)TestBCD2016-1(Answer)
TestBCD2016-1(Answer)
 
아두이노 2015-2 한동대학교 공학설계입문
아두이노 2015-2 한동대학교 공학설계입문아두이노 2015-2 한동대학교 공학설계입문
아두이노 2015-2 한동대학교 공학설계입문
 
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
2017 Software Edu Fest - 생활속데이터 이야기 @ 세상을 변화시키는 소프트웨어 기술
 
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
컵드론 멀티콥터 펌웨어 분석 2015. 3.28.
 
Cubietruck 리눅스 이미지 설치
Cubietruck 리눅스 이미지 설치Cubietruck 리눅스 이미지 설치
Cubietruck 리눅스 이미지 설치
 
[2] 아두이노 활용 실습
[2] 아두이노 활용 실습[2] 아두이노 활용 실습
[2] 아두이노 활용 실습
 
Wiznet Academy - WizFi250 기초교육 및 실습
Wiznet Academy - WizFi250 기초교육 및 실습Wiznet Academy - WizFi250 기초교육 및 실습
Wiznet Academy - WizFi250 기초교육 및 실습
 
02. led switch
02. led switch02. led switch
02. led switch
 
Interrupt @atmega
Interrupt @atmegaInterrupt @atmega
Interrupt @atmega
 
Interrupt @atmega
Interrupt @atmegaInterrupt @atmega
Interrupt @atmega
 
Tips and experience of DX12 Engine development .
Tips and experience of DX12 Engine development .Tips and experience of DX12 Engine development .
Tips and experience of DX12 Engine development .
 
TestBCD2017-1(answer)
TestBCD2017-1(answer)TestBCD2017-1(answer)
TestBCD2017-1(answer)
 
라즈베리파이 Circulus API 가이드
라즈베리파이 Circulus API 가이드라즈베리파이 Circulus API 가이드
라즈베리파이 Circulus API 가이드
 
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이  왜 이리 힘드나요?  (Lock-free에서 Transactional Memory까지)
Ndc2014 시즌 2 : 멀티쓰레드 프로그래밍이 왜 이리 힘드나요? (Lock-free에서 Transactional Memory까지)
 
Let's geek! (1)
Let's geek! (1) Let's geek! (1)
Let's geek! (1)
 
김성윤 - 우분투로 슈퍼컴 만들기 (2011Y03M26D)
김성윤 - 우분투로 슈퍼컴 만들기 (2011Y03M26D)김성윤 - 우분투로 슈퍼컴 만들기 (2011Y03M26D)
김성윤 - 우분투로 슈퍼컴 만들기 (2011Y03M26D)
 
TestBCD2015-1(Answer)
TestBCD2015-1(Answer)TestBCD2015-1(Answer)
TestBCD2015-1(Answer)
 
Mikrotic CCR1036 라우팅 설정
Mikrotic CCR1036 라우팅 설정Mikrotic CCR1036 라우팅 설정
Mikrotic CCR1036 라우팅 설정
 

Mehr von 봉조 김

창의·융합·문제해결을 배우는 메이커 활동 리스트
창의·융합·문제해결을 배우는 메이커 활동 리스트창의·융합·문제해결을 배우는 메이커 활동 리스트
창의·융합·문제해결을 배우는 메이커 활동 리스트봉조 김
 
Softboxcoding brand name
Softboxcoding brand nameSoftboxcoding brand name
Softboxcoding brand name봉조 김
 
Weather station performance sharing
Weather station performance sharingWeather station performance sharing
Weather station performance sharing봉조 김
 
Aircleaner 20190616 - 미세먼지 공기청정기 메이커활동 제안서
Aircleaner 20190616 - 미세먼지 공기청정기 메이커활동 제안서Aircleaner 20190616 - 미세먼지 공기청정기 메이커활동 제안서
Aircleaner 20190616 - 미세먼지 공기청정기 메이커활동 제안서봉조 김
 
Softbox coding - raspberrypi3 b+ 2019 Lecture File
Softbox coding - raspberrypi3 b+ 2019 Lecture File Softbox coding - raspberrypi3 b+ 2019 Lecture File
Softbox coding - raspberrypi3 b+ 2019 Lecture File 봉조 김
 
Sw education and maker
Sw education and makerSw education and maker
Sw education and maker봉조 김
 
소프트박스 라즈베리파이 교육키트 개발환경 설정
소프트박스 라즈베리파이 교육키트 개발환경 설정소프트박스 라즈베리파이 교육키트 개발환경 설정
소프트박스 라즈베리파이 교육키트 개발환경 설정봉조 김
 
Expansion of maker culture and promotion of maker activity
Expansion of maker culture and promotion of maker activityExpansion of maker culture and promotion of maker activity
Expansion of maker culture and promotion of maker activity봉조 김
 
2018년 따복공동체 활동 공유 - 과천 디지털 창작집단
2018년 따복공동체 활동 공유 - 과천 디지털 창작집단2018년 따복공동체 활동 공유 - 과천 디지털 창작집단
2018년 따복공동체 활동 공유 - 과천 디지털 창작집단봉조 김
 
강사료 원천징수 관련 설명자료
강사료 원천징수 관련 설명자료강사료 원천징수 관련 설명자료
강사료 원천징수 관련 설명자료봉조 김
 
Softbox review and quickstartguide-20180926
Softbox review and quickstartguide-20180926Softbox review and quickstartguide-20180926
Softbox review and quickstartguide-20180926봉조 김
 
디지털창작집단 활동 소개문서
디지털창작집단 활동 소개문서디지털창작집단 활동 소개문서
디지털창작집단 활동 소개문서봉조 김
 
Softbox arduino software education, softbox 소프트박스 제품소개서
Softbox arduino software education, softbox 소프트박스 제품소개서 Softbox arduino software education, softbox 소프트박스 제품소개서
Softbox arduino software education, softbox 소프트박스 제품소개서 봉조 김
 
Stuffed animals 20180605
Stuffed animals 20180605Stuffed animals 20180605
Stuffed animals 20180605봉조 김
 
20180329 reco computer for maker
20180329 reco computer for maker20180329 reco computer for maker
20180329 reco computer for maker봉조 김
 
2018 donga marathon training schedule
2018 donga marathon training schedule2018 donga marathon training schedule
2018 donga marathon training schedule봉조 김
 
2017 marathob trainning schedule
2017 marathob trainning schedule2017 marathob trainning schedule
2017 marathob trainning schedule봉조 김
 
Marathon safe guide
Marathon safe guideMarathon safe guide
Marathon safe guide봉조 김
 
사물인터넷서비스와 클라우드
사물인터넷서비스와 클라우드사물인터넷서비스와 클라우드
사물인터넷서비스와 클라우드봉조 김
 
4차 산업혁명과 io t 20170919
4차 산업혁명과 io t  201709194차 산업혁명과 io t  20170919
4차 산업혁명과 io t 20170919봉조 김
 

Mehr von 봉조 김 (20)

창의·융합·문제해결을 배우는 메이커 활동 리스트
창의·융합·문제해결을 배우는 메이커 활동 리스트창의·융합·문제해결을 배우는 메이커 활동 리스트
창의·융합·문제해결을 배우는 메이커 활동 리스트
 
Softboxcoding brand name
Softboxcoding brand nameSoftboxcoding brand name
Softboxcoding brand name
 
Weather station performance sharing
Weather station performance sharingWeather station performance sharing
Weather station performance sharing
 
Aircleaner 20190616 - 미세먼지 공기청정기 메이커활동 제안서
Aircleaner 20190616 - 미세먼지 공기청정기 메이커활동 제안서Aircleaner 20190616 - 미세먼지 공기청정기 메이커활동 제안서
Aircleaner 20190616 - 미세먼지 공기청정기 메이커활동 제안서
 
Softbox coding - raspberrypi3 b+ 2019 Lecture File
Softbox coding - raspberrypi3 b+ 2019 Lecture File Softbox coding - raspberrypi3 b+ 2019 Lecture File
Softbox coding - raspberrypi3 b+ 2019 Lecture File
 
Sw education and maker
Sw education and makerSw education and maker
Sw education and maker
 
소프트박스 라즈베리파이 교육키트 개발환경 설정
소프트박스 라즈베리파이 교육키트 개발환경 설정소프트박스 라즈베리파이 교육키트 개발환경 설정
소프트박스 라즈베리파이 교육키트 개발환경 설정
 
Expansion of maker culture and promotion of maker activity
Expansion of maker culture and promotion of maker activityExpansion of maker culture and promotion of maker activity
Expansion of maker culture and promotion of maker activity
 
2018년 따복공동체 활동 공유 - 과천 디지털 창작집단
2018년 따복공동체 활동 공유 - 과천 디지털 창작집단2018년 따복공동체 활동 공유 - 과천 디지털 창작집단
2018년 따복공동체 활동 공유 - 과천 디지털 창작집단
 
강사료 원천징수 관련 설명자료
강사료 원천징수 관련 설명자료강사료 원천징수 관련 설명자료
강사료 원천징수 관련 설명자료
 
Softbox review and quickstartguide-20180926
Softbox review and quickstartguide-20180926Softbox review and quickstartguide-20180926
Softbox review and quickstartguide-20180926
 
디지털창작집단 활동 소개문서
디지털창작집단 활동 소개문서디지털창작집단 활동 소개문서
디지털창작집단 활동 소개문서
 
Softbox arduino software education, softbox 소프트박스 제품소개서
Softbox arduino software education, softbox 소프트박스 제품소개서 Softbox arduino software education, softbox 소프트박스 제품소개서
Softbox arduino software education, softbox 소프트박스 제품소개서
 
Stuffed animals 20180605
Stuffed animals 20180605Stuffed animals 20180605
Stuffed animals 20180605
 
20180329 reco computer for maker
20180329 reco computer for maker20180329 reco computer for maker
20180329 reco computer for maker
 
2018 donga marathon training schedule
2018 donga marathon training schedule2018 donga marathon training schedule
2018 donga marathon training schedule
 
2017 marathob trainning schedule
2017 marathob trainning schedule2017 marathob trainning schedule
2017 marathob trainning schedule
 
Marathon safe guide
Marathon safe guideMarathon safe guide
Marathon safe guide
 
사물인터넷서비스와 클라우드
사물인터넷서비스와 클라우드사물인터넷서비스와 클라우드
사물인터넷서비스와 클라우드
 
4차 산업혁명과 io t 20170919
4차 산업혁명과 io t  201709194차 산업혁명과 io t  20170919
4차 산업혁명과 io t 20170919
 

Avr lecture8

  • 2. --22--20062006--0404--0808 Embedded AVR ProgrammingEmbedded AVR Programming ATMEGA128ATMEGA128의의 실전실전 ⅡⅡ 1. RTC란 2. DS1302를 이용한 RTC 실습
  • 3. --33--20062006--0404--0808 Embedded AVR ProgrammingEmbedded AVR Programming 1-1 RTC (Real Time Clock)이란? ⊙ 실시간 시계. 전원 공급이 안 되어도 현재의 시간을 지키는 시계 ⊙ DS1302란? - Trickle charge RTC (세류 충전 계시 칩, 혹은 트리클 충전 계시 칩) - Trickle => 물방울, 졸졸 흐르는 시내물. 적은 전류로 충전(==> 동작)하는 RTC라고 생각하면 됨 - DS1302는 내부에 여러 개의 데이터 영역을 가지고 있으며, 각각의 영역마다 초, 분, 시, 년, 월, 일 등의 데이터를 기록하고, 자동으로 갱신시켜 줌. 유저는 단지 이 데이터를 읽어와 사용
  • 4. --44--20062006--0404--0808 Embedded AVR ProgrammingEmbedded AVR Programming 1-2 DS1302를 이용한 RTC ⊙ 핀 정리 1 : VCC2 : 메인 전원용 VCC와 연결 2, 3 : X1, X2 : 32768 크리스털과 연결 4 : GND : 전원 그라운드 5 : #RST : 칩 선택용이니 CS(chip enable) 6 : I/O : 시리얼 데이터를 주고 받는 포트 7 : SCLK : 시리얼 클럭. 데이터를 주고 받을 때 사용하는 클럭 8 : VCC1 : 백업용 배터리를 연결
  • 5. --55--20062006--0404--0808 Embedded AVR ProgrammingEmbedded AVR Programming 1-2 DS1302를 이용한 RTC ⊙ 회로도 U5 DS1302SN/SOIC X1 2 X2 3 GND 4 RST 5 I/O 6 SCLK 7 VCC2 1 VCC1 8 X1 32.768KHz BT1 TL5101 JP12 HEADER/2X3 1 2 3 4 5 6 RTC.BAT #BIT.RST #BIT.SLK BIT.IO VCC I2C/RTC VCC.BAT D1 1N5819 D2 1N5819 VCC
  • 6. --66--20062006--0404--0808 Embedded AVR ProgrammingEmbedded AVR Programming 1-2 DS1302를 이용한 RTC ⊙ DS1302의 내부 데이터 영역도
  • 7. --77--20062006--0404--0808 Embedded AVR ProgrammingEmbedded AVR Programming 1-2 DS1302를 이용한 RTC ⊙ 명령 및 어드레스, 데이터 송수신 순서
  • 8. --88--20062006--0404--0808 Embedded AVR ProgrammingEmbedded AVR Programming 1-3 DS1302를 이용한 RTC 실습 1 ☞ DS1302를 이용한 Real Time Clock 를 LCD로 표시하는 프로그램 // timer 0 overflow ISR interrupt [TIM0_OVF] void timer0_ovf_isr(void) { TCNT0 = 6; // reload for 1ms ticks if(++timecount == 500) // 500ms 마다 업데이트 { tick1flag = 1; timecount = 0; // clear for next 500ms } } void main(void) { unsigned char h,m,s,i; MCUCR=0xc0; // am_lcd함수 사용시 //Port D PORTD = 0xff; DDRD = 0xff; TCNT0 = 0x00; // reset TCNT0 TCCR0 = 0x04; // count with cpu clock/64 (64/16MHz=4ms) TIMSK = 0x01; // enable TCNT0 overflow #include <mega128.h> #include <stdio.h> #include <delay.h> #include "am_lcd.h" #include "am_lcd.c" // DS1302 Real Time Clock functions #asm .equ __ds1302_port=0x12 ;PORTD .equ __ds1302_io=4 .equ __ds1302_sclk=5 .equ __ds1302_rst=2 #endasm #include <ds1302.h> char rtc_buf[16]; // lcd display temp buffer char lcd_state; bit tick1flag=0; unsigned int timecount = 0; // global time counter
  • 9. --99--20062006--0404--0808 Embedded AVR ProgrammingEmbedded AVR Programming 1-3 DS1302를 이용한 RTC 실습 1 ☞ DS1302를 이용한 Real Time Clock 를 LCD로 표시하는 프로그램 while(1) { if (tick1flag) // 0.5초마다 업데이트 { if(i==0) { i=1; lcd_state = 43; // "X"를 표시 } else { i=0; lcd_state = 120; // "+"를 표시 } lcd_clear(); Gotoxy(0,0); _lcd_str(" M128 RTC TEST1 "); sprintf(rtc_buf,"%c TIME %2d:%2d:%2d",lcd_state ,h,m,s,lcd_state); Gotoxy(0,1); // LCD 둘째 줄 왼쪽 처음으로 이동 lcd_str(rtc_buf); // LCD에 tpbuf 표시 tick1flag = 0; } rtc_get_time(&h,&m,&s); // DS1302에서 시간데이터 얻기 } } #asm("sei"); // DS1302 Real Time Clock initialization // Trickle charger: On // Trickle charge resistor: None // Trickle charge diode(s): 1 rtc_init(1,1,0); /* initialize the LCD for 2 lines & 16 columns */ lcd_init(); Gotoxy(0,0); _lcd_str(" ::AVRMall::"); Gotoxy(0,1); _lcd_str("Real Time Clock 1"); rtc_set_time(12,0,0); //rtc_set_date(15,6,4); delay_ms(2000);