20
Einleitung Wie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel Einf¨ uhrung Microcontroller Lucian Landgraf 18. Januar 2011 Lucian Landgraf Einf¨ uhrung Microcontroller

Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

  • Upload
    lengoc

  • View
    237

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Einfuhrung Microcontroller

Lucian Landgraf

18. Januar 2011

Lucian Landgraf Einfuhrung Microcontroller

Page 2: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Inhaltsverzeichnis

1 Einleitung

2 Wie steuert man einen Microcontroller?

3 AVR-Microcontroller

4 AVR-Assembler

5 Beispiel

Lucian Landgraf Einfuhrung Microcontroller

Page 3: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Was ist eigentlich ein Microcontroller?

Lucian Landgraf Einfuhrung Microcontroller

Page 4: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Microcontroller - Was ist das?

Microcontroller enthalten:

integrierte und gleichzeitig programmierbare Schaltungen,

Prozessoren, Speicher,

digitale und analoge Ein- und Ausgange,

Programme, die den Funktionsablauf steuern

Lucian Landgraf Einfuhrung Microcontroller

Page 5: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Microcontroller - Wofur braucht man das?

Microcontroller befinden sich in:

in fast allen elektronisch kontrollierten Geraten, z.B.

ABS-Systemen,

Haushaltsgeraten,

Fotoapparaten usw.

Lucian Landgraf Einfuhrung Microcontroller

Page 6: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Wie wird ein Microcontroller gesteuert und was wird dazubenotigt?

Lucian Landgraf Einfuhrung Microcontroller

Page 7: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Sprachen

Programme werden vorwiegend in folgenden Sprachen geschreiben:

Assembler,

C,C++,

Basic,

Pascal,

usw.

Lucian Landgraf Einfuhrung Microcontroller

Page 8: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Hardware

Was braucht man:

Spannungsversorgung,

Taster, z.B. fur Reset,

LEDs,

Taktgeber,

Diverse Kabel,

USB-Adapter, Programmer

Lucian Landgraf Einfuhrung Microcontroller

Page 9: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Fertige Entwicklerboard

Abbildung: RN-Control Quelle:http://www.rn-wissen.de/index.php/RN-Control

Lucian Landgraf Einfuhrung Microcontroller

Page 10: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Warum AVR-µC

AVR-µC sind:

weitverbreitet,

relativ billig,

sich alle sehr ahnlich,

durch viel kostenloseSoftware bedienbar

RISC-Architektur Abbildung: Atmel-µC Quelle:http://de.wikipedia.org/wiki/Atmel AVR

Lucian Landgraf Einfuhrung Microcontroller

Page 11: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Wichtige Teile eines AVR-µC

32 Register

integrierter Flash-Speicher

Schreib- und Lese-Ports

interner Oszillator

interne Timer

. . . Abbildung: Pin-Belegung desAtmega8 Quelle:http://www.atmel.com/dyn/resources/prod documents/doc2486.pdf

Lucian Landgraf Einfuhrung Microcontroller

Page 12: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Vorteile von Assembler

relativ leicht zu erlernen

Prozessor macht genau das, was er soll

Verstandnis des µC-Aufbaus

Lucian Landgraf Einfuhrung Microcontroller

Page 13: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

LEDs und Taster des STK500

Abbildung: Verschaltung einerLED

Abbildung: Verschaltung einesTasters

Quelle: http://www.atmel.com/dyn/resources/prod documents/doc1925.pdf

Lucian Landgraf Einfuhrung Microcontroller

Page 14: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Beispielprogramm des STK500

;∗∗∗∗∗ STK500 LEDS and SWITCH demons t r a t i on. i n c l u d e ’ 8515 de f . i n c ’. d e f Temp =r16 ; Temporary r e g i s t e r. d e f Delay =r17 ; Delay v a r i a b l e 1. d e f Delay2 =r18 ; Delay v a r i a b l e 2

Lucian Landgraf Einfuhrung Microcontroller

Page 15: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Beispielprogramm des STK500

;∗∗∗∗∗ I n i t i a l i z a t i o nRESET :s e r Tempout DDRB,Temp ; Set PORTB to output

Lucian Landgraf Einfuhrung Microcontroller

Page 16: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Beispielprogramm des STK500

;∗∗∗∗ Test i n pu t / outputLOOP:out PORTB, temp ; Update LEDSs b i s PIND ,0 x00 ; I f ( Port D, p in0 == 0)i n c Temp ; then count LEDS one downs b i s PIND ,0 x01 ; I f ( Port D, p in1 == 0)dec Temp ; then count LEDS one ups b i s PIND ,0 x02 ; I f ( Port D, p in2 == 0)r o r Temp ; then r o t a t e LEDS one r i g h ts b i s PIND ,0 x03 ; I f ( Port D, p in3 == 0)r o l Temp ; then r o t a t e LEDS one l e f ts b i s PIND ,0 x04 ; I f ( Port D, p in4 == 0)com Temp ; then i n v e r t a l l LEDSs b i s PIND ,0 x05 ; I f ( Port D, p in5 == 0)neg Temp ; then i n v e r t a l l LEDS and add 1s b i s PIND ,0 x06 ; I f ( Port D, p in6 == 0)swap Temp ; then swap n i b b l e s o f LEDS

Lucian Landgraf Einfuhrung Microcontroller

Page 17: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Beispielprogramm des STK500

;∗∗∗∗ Now wa i t a wh i l e to make LED changes v i s i b l e .DLY:dec Delaybrne DLYdec Delay2brne DLYrjmp LOOP ; Repeat l oop f o r e v e r

Lucian Landgraf Einfuhrung Microcontroller

Page 18: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Quellen

www.mikrocontroller.net/articles/AVR-Tutorial

www.rn-wissen.de/index.php/Avr

www.rn-wissen.de/index.php/Microcontroller

www.avr-asm-tutorial.net/avr de/beginner/index.html

Lucian Landgraf Einfuhrung Microcontroller

Page 19: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Fragen

Hat jemand eine Frage?

Lucian Landgraf Einfuhrung Microcontroller

Page 20: Einf uhrung Microcontroller - Projektlabor Forum · PDF fileWie steuert man einen Microcontroller? AVR-Microcontroller AVR-Assembler Beispiel ... AVR- C sind: weitverbreitet, relativ

EinleitungWie steuert man einen Microcontroller?

AVR-MicrocontrollerAVR-Assembler

Beispiel

Vielen Dank fur eure Aufmerksamkeit!

Lucian Landgraf Einfuhrung Microcontroller