31
2주차 주차 ATmega128 ATmega128의 내부 내부 구조 구조 및 퓨즈 퓨즈 비트 비트 설정 설정 Next-Generation Networks Lab.

22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

Embed Size (px)

Citation preview

Page 1: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

22주차주차ATmega128ATmega128의의 내부내부 구조구조 및및 퓨즈퓨즈 비트비트 설정설정

Next-Generation Networks Lab.

Page 2: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

4. ATmega1284. ATmega128의의 클럭시스템과클럭시스템과 배분배분

시스템 클럭• 마이크로컨트롤러 동작의 기준이 되는 클럭의 주파수

시 템 럭 내 별 립적 배 하여 제어• AVR은 시스템 클럭을 내부 모듈별로 독립적으로 배분하여 제어

• 슬립(Sleep)모드를 활용하여 내부 모듈별로 클럭 차단이 가능하여 전력소모 관리

• 퓨즈 비트를 통해 다양한 클럭 소스 선택 가능퓨즈 비트를 통해 다양한 클럭 소스 선택 가능

클럭 배분 (표 2-13)

번호 클럭 설명

1 clkASY 비동기 타이머/카운터 (Asynchronous Timer/Counter)1 clkASY 비동기 타이머/카운터 (Asynchronous Timer/Counter)

2 clkI/O 범용 I/O 모듈 (General I/O Modules)

3 clk 아날로그-디지털 변환기 (ADC)3 clkADC 아날로그-디지털 변환기 (ADC)

4 clkCPU CPU 핵심모듈 (CPU Core), SRAM

5 clk 메모리 (Flash and EEPROM)

35

5 clkFLASH 메모리 (Flash and EEPROM)

Page 3: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

ATmega128ATmega128의의 블럭도블럭도

입출력장치

메모리 주변장치

36

Page 4: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

그림그림 22--19 AVR19 AVR의의 시스템시스템 클럭과클럭과 배분배분 블럭도블럭도

시스템클럭배분

시스템클럭시스템클럭

시스템클럭

37

시스템클럭Source

Page 5: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

Clock SourceClock Source의의 종류종류 ((표표22--14, 14, 표표22--15)15)

Clock Source는 Fuse bit에서 CKSEL[3:0]의 설정에 의해 선택

번호 Clock Source CKSEL[3..0]

1 외부 크리스털 혹은 세라믹 레조네이터(E t l C t l/C i R t )

1111 ~ 10101 외부(External Crystal/Ceramic Resonator)

1111 1010

2 외부 저주파 크리스털 (External Low-frequency Crystal) 1001

3 외부 RC 오실레이터 (External RC Oscillator) 1000 ~ 0101

4 내부 RC 오실레이터 (Calibrated Internal RC Oscillator) 0100 ~ 00010001내부 실레이터 ( )

5 외부 클럭 (External Clock) 0000

Default Clock Source CKSEL[3:0]=[0001], SUT[1:0]=[10]으로 설정

내부 RC 오실레이터가 1MHz로 동작

38

내부 실레이터가 동작

Page 6: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

39

Page 7: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

①① External Crystal or Ceramic Resonator (External Crystal or Ceramic Resonator (그림그림22--20, 20, 표표22--16)16)

40

Page 8: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

표표 22--1717

41

Page 9: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

②② LL f C t l O ill tf C t l O ill t②② LowLow--frequency Crystal Oscillator frequency Crystal Oscillator ((그림그림 22--21)21)

③③ E t l RC O ill tE t l RC O ill t③③ External RC OscillatorExternal RC Oscillator((그림그림 22--22)22)

32.768kHz32.768kHz

42

Page 10: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

④④ 내부내부 RC RC 오실레이터오실레이터 (Calibrated Internal RC Oscillator)(Calibrated Internal RC Oscillator)

Fuse 비트에서 CKOPT는 반드시 ‘1’로 설정

XTAL1과 XTAL2 핀에는 아무것도 연결하지 않음XTAL1과 XTAL2 핀에는 아무것도 연결하지 않음

표 2-21

표 2-22

43

Page 11: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

⑤⑤ External OscillatorExternal Oscillator((그림그림 22--24)24)

⑥⑥ 타이머타이머//카운터카운터 오실레이터오실레이터

TOSC1과 TOSC2 핀에 32.768kHz의 크리스털을 직접 연결

외부에 커패시터는 연결하지 않음

44

Page 12: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

5. 5. 전원전원 관리관리 및및 슬립슬립 모드모드

슬립 모드 (Sleep modes)

• AVR 내의 모듈 중 사용하지 모듈의 전원 공급을 차단함으로써 전력을 절감

• 6가지의 다양한 슬립모드를 지원함으로써 원하는 모듈만 전원을 공급/차단

• MCUCR 레지스터 설정 후 SLEEP 명령어 실행레지스터 설정 후 명령어 실행

• 단, 마이크로컨트롤러가 슬립 상태라 하더라도 인터럽트가 발생하면 깨어남

번호 슬립 모드 SM 비트

1 아이들 모드 (Idle Mode) 000

표 2-24

표 2-26

2 ADC 노이즈 감소 모드 (ADC Noise Reduction Mode) 001

3 파워-다운 모드(Power-down Mode) 010

4 파워 세이브 모드 (Power-save Mode) 011

5 스탠바이 모드(Standby Mode) 110

45

6 확장 스탠바이 모드 (Extended Standby Mode) 111

Page 13: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

MCUCR (MCU Control Register) 그림 2-25

비트 이름 기능

7 SRE외부 메모리 사용 관련 설정외부 메모리 사용 관련 설정

6 SRW10

5 SE Sleep Enable

표 2-25

4 SM1 Sleep Mode Select 1

3 SM0 Sleep Mode Select 0

2 SM2 Sleep Mode Select 2

1 IVSEL인터럽트 벡터 설정 관련인터럽트 벡터 설정 관련

0 IVCE

46

Page 14: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

표표 22--27 27 슬립모드에서슬립모드에서 활성화활성화 클럭클럭 영역과영역과 WakeWake--up sourceup source

47

Page 15: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

6. 6. 시스템시스템 제어제어 및및 리셋리셋

리셋 ? 모든 레지스터가 기본값으로 초기화되고,

프로그램은 리셋 벡터부터 다시 시작

리셋 ( 2 28)

프로그램은 리셋 벡터부터 다시 시작

리셋 소스 (표2-28)

번호 클럭 설명

1파워온 리셋(Power-on Reset)

전원 전압 VCC가 일정 전압 VPOT 이하로 떨어지면 리셋

2외부 리셋(External Reset)

/RESET 핀에 LOW 입력이 일정 전압 VRST 이하로1.5usec 이상 유지되면 리셋

브라운아웃검출 리셋 BOD 검출 전압이 일정 전압 V 이하로3

브라운아웃검출 리셋(Brown-out Detection)

BOD 검출 전압이 일정 전압 VBOT 이하로2.0usec 이상 떨어지면 리셋

4와치독 리셋

Watchdog 타임아웃이 발생하면 리셋

48

4와치독 리셋(Watchdog Reset)

Watchdog 타임아웃이 발생하면 리셋

Page 16: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

그림그림22--26 26 리셋리셋 블록블록 다이어그램다이어그램

49

Page 17: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

POR (PowerPOR (Power--On Reset)On Reset)

그림 2-23 POR (1)

그림 2-27 POR (2)

50

Page 18: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

그림 2-28 EXT

Fuse 비트에서 BODLEVEL과 BODEN 비트 설정

그림 2 29 BOD그림 2-29 BOD

51

Page 19: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

그림 2-30 WDT

MCUCSR (MCU Control and Status Register) 리셋 source를 표시

그림 2-31

52

그림 2 31

Page 20: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

7. 7. 와치독와치독 타이머타이머

와치독(Watchdog) 이란?• ‘집 지키는 강아지’, ‘경비견’ 이라는 뜻으로 안정성을 향상시키는 기술

외 럭과 별 내 의 립적인 럭 사• 외부 클럭과 별도로 내부의 독립적인 1MHz 클럭을 사용

그림 2-32

53

Page 21: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

WDTCR (Watchdog Timer Control Register) 그림 2-33

WDP2

표 2-29 와치독 타이머의 분주비 설정

번호 WDP2 WDP1 WDP0 와치독 분주비 타임아웃(VCC=3.0) 타임아웃(VCC=5.0)

1 0 0 0 16,384 (16K) 17.1 ms 16.3 ms2 0 0 1 32 768 (32K) 34 3 ms 32 5 ms2 0 0 1 32,768 (32K) 34.3 ms 32.5 ms3 0 1 0 655,36 (64K) 68.5 ms 65 ms4 0 1 1 131,072 (128K) 0.14 ms 0.13 sec5 1 0 0 262,144 (256K) 0.27 ms 0.26 sec6 1 0 1 524,288 (512K) 0.55 ms 0.52 sec7 1 1 0 1,048,576 (1,024K) 1.1 sec 1.0 sec

54

7 1 1 0 1,048,576 (1,024K) 1.1 sec 1.0 sec8 1 1 1 2,097,152 (2,048K) 2.2 sec 2.1 sec

Page 22: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

8. 8. 메모리메모리 락락 비트와비트와 퓨즈퓨즈 비트비트

1바이트의 메모리 락 비트 와 3바이트의 퓨즈 비트로 구성

메모리 락 비트 (Memory Lock Bit) 메모리의 내용을 보호

퓨즈 비트 (Fuse Bit) 디바이스의 기능 및 상태를 설정

메모리 락 비트는 “Chip Erase”명령에 의해서 초기값인 ‘1’로 설정가능

퓨즈 비트는 “Chip Erase”명령에 의해서 영향을 받지 않음

메모리 락 비트를 프로그램하기 전에 퓨즈 비트를 먼저 프로그램할 것

메모리 락 비트의 LB1이 프로그램(0)되면 퓨즈 비트는 락(l k)됨메모리 락 비트의 LB1이 프로그램(0)되면 퓨즈 비트는 락(lock)됨

• 해당 비트의 내용을 반드시 숙지 하고 설정할 것!! 잘 모르고 아무렇게• 해당 비트의 내용을 반드시 숙지 하고 설정할 것!! 잘 모르고 아무렇게세팅할 경우 AVR이 오동작할 우려가 있음

• 특히 크리스털 관련 설정에 주의할 것

55

Page 23: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

표표22--32 32 메모리메모리 락락 비트비트 (Memory Lock Bit)(Memory Lock Bit)

비트 이름 모드 및 기능기본설정

설정의미

5 BLB12 Boot Lock Bit 12 BLB1 모드 Bootloader section에서SPM과 LPM의 제약여부를 설정

1쓰기금지

없음4 BLB11 Boot Lock Bit 11 1SPM과 LPM의 제약여부를 설정4 BLB11 Boot Lock Bit 11 1

3 BLB02 Boot Lock Bit 02 BLB0 모드 A li i i 에서

1쓰기금지

Application section에서SPM과 LPM의 제약여부를 설정

쓰기금지없음

2 BLB01 Boot Lock Bit 01 1

1 LB2 Lock Bit 2 LB 모드 Flash와 EEPROM의 프로그래밍 가능 여부를 설정

1쓰기금지

없음0 LB1 Lock Bit 1 1

0xFF

56

Page 24: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

퓨즈퓨즈 비트비트

확장 퓨즈 바이트

퓨즈 상위 바이트 퓨즈 상위 바이트

퓨즈 하위 바이트

비트 이름 기능 기본설정 수정설정

표2-34 확장 퓨즈 바이트 (Extended Fuse Byte)

비 이름 기능 기본설정 수정설정

1 M103C ATmega103 compatible mode 0 1

0 WDTON Watchdog Timer Active 1 10 WDTON Watchdog Timer Active 1 1

0 P d Ch k d E bl d 설정

0xFF0 Programmed Checked Enabled 설정

1 UnProgrammed Unchecked Disabled 해제

57

Page 25: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

비트 이름 기 능 기본 설정 수정 설정

표2-35 퓨즈 비트 상위 바이트 (Fuse High Byte)

비트 이름 기 능 기본 설정 수정 설정

7 OCDEN OCD Enable 1 1

6 JTAGEN JTAG Enable 0 1

5 SPIEN SPI Enable for Downloading 0 0

4 CKOPT Clock Options (Full swing) 1 1

3 EESAVE EEPROM Save @ Chip Erase 1 1

2 BOOTSZ1 Select Boot Size (11:512, 10:1024, 01:2048, 00:4096)

0 0

1 BOOTSZ0 0 0

0 BOOTRST Select Boot Reset Vector 1 1

0x??

58

Page 26: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

비트 이름 기 능 기본 설정 수정 설정

표2-36 퓨즈 비트 하위 바이트 (Fuse Low Byte)

비트 이름 기 능 기본 설정 수정 설정

7 BODLEVEL BOD Trigger Level Select 1 1

6 BODEN BOD Enable 1 1

5 SUT1 Select SUT(Start-up Time) 1 1

4 SUT0 0 0

3 CKSEL3 Select Clock Source 0 0

( Default SUT 64ms )

(표2-37 참고)2 CKSEL2 0 0

1 CKSEL1 0 0Default Clock Source

0 CKSEL0 1 1

0x??

내부 RC 오실레이터 1MHz

59

Page 27: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

종류 클럭 소스 주파수(MHz) CKSEL3 0

표2-37 클럭 비트 설정 CKSEL3..0

종류 클럭 소스 주파수(MHz) CKSEL3..0

1 External Crystal/Ceramic Resonator 1111 ~ 1010

2 External Low-Frequency Crystal 1001te a o eque cy C ysta 00

3 E ternal RC Oscillator

8.0 ~ 12.0 1000

3.0 ~ 8.0 01113 External RC Oscillator

0.9 ~ 3.0 0110

0.1 ~ 0.9 0101

4 Calibrated Internal RC Oscillator

8.0 0100

4.0 00114 Calibrated Internal RC Oscillator

2.0 0010

1.0 0001

5 E t l Cl k 00005 External Clock 0000

60

Page 28: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

0x00 번지 0x01 번지 0x02 번지 모델

표2-38 제품 표시 바이트 (Signature Bytes)

0x97(128KB Flash 모델을 의미)

0x01 ATmega103

0x02 ATmega128

0x03 ATmega1280( 델을 의미) 0x03 ATmega1280

0x04 ATmega1281

0x960x01 -

0x1E

(At l 제품을 의미)

0x96(64KB Flash 모델을 의미)

0x02 ATmega64

0x03 ATmega640

0x95 0x01(Atmel 제품을 의미) 0x95(32KB Flash 모델을 의미)

0x01

0x02

0x01 ATmega161

0x94(16KB Flash 모델을 의미)

0x02 ATmega163

0x03 ATmega16

0x04 ATmega1620x04 ATmega162

0x05 ATmega169

61

Page 29: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

ISP 방식의 프로그래머를 지원하는 소프트웨어

소프트웨어 제조회사 교재 지원되는 부품

Atmel Studio 6.2

(Atmel Studio 4.18)Atmel 그림 2-36

Atmel 사의 AVR 계열

Atmel 사의 8051 계열

ToastProgUSB

(T tP 2005)Seniorcom 그림 2-35

Atmel 사의 AVR 계열

At l 사의 8051 계열(ToastProg2005) Atmel 사의 8051 계열

Atmel 사의 AVR 계열

PonyProg2000 Freeware 그림 2-34 Atmel 사의 8051 계열

PIC, EEPROM 등등

62

Page 30: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

Atmel Studio Atmel Studio 의의 Lock & Fuse bits Lock & Fuse bits 설정설정 ((그림그림 22--36)36)

Default 상태내부 RC 오실레이터 1MHz

0xFF0xD9

63

Start-up time: 64ms0xE1

Page 31: 22주차주차 …contents.kocw.net/KOCW/document/2015/shinhan/leesangrok/2.pdf · 2 ADC 노이즈감소모드(ADC Noise Reduction Mode) 001 3 파워-다운모드(Power-down Mode)

ToastprogUSBToastprogUSB의의 Lock & Fuse bits Lock & Fuse bits 설정설정 ((그림그림 22--35)35)

Default 상태0xFF 0xFF 0xD9 0xE1 내부 RC 오실레이터 1MHz

Start-up time: 64ms

64