Introduction to microcontrollers.pdf

(2159 KB) Pobierz
394954980 UNPDF
IntroductiontoMicrocontrollers
Courses182.064&182.074
ViennaUniversityofTechnology
InstituteofComputerEngineering
EmbeddedComputingSystemsGroup
February26,2007
Version1.4
G¨untherGridling,BettinaWeiss
Contents
1MicrocontrollerBasics 1
1.1Introduction ....................................... 1
1.2FrequentlyUsedTerms ................................. 6
1.3Notation ......................................... 7
1.4Exercises ........................................ 8
2MicrocontrollerComponents 11
2.1ProcessorCore ..................................... 11
2.1.1Architecture ................................... 11
2.1.2InstructionSet ................................. 15
2.1.3Exercises .................................... 21
2.2Memory ......................................... 22
2.2.1VolatileMemory ................................ 23
2.2.2Non-volatileMemory .............................. 27
2.2.3AccessingMemory ............................... 29
2.2.4Exercises .................................... 31
2.3DigitalI/O ........................................ 33
2.3.1DigitalInput .................................. 34
2.3.2DigitalOutput ................................. 38
2.3.3Exercises .................................... 39
2.4AnalogI/O ....................................... 40
2.4.1Digital/AnalogConversion ........................... 40
2.4.2AnalogComparator ............................... 41
2.4.3Analog/DigitalConversion ........................... 42
2.4.4Exercises .................................... 51
2.5Interrupts ........................................ 52
2.5.1InterruptControl ................................ 52
2.5.2InterruptHandling ............................... 55
2.5.3InterruptServiceRoutine ............................ 57
2.5.4Exercises .................................... 59
2.6Timer .......................................... 60
2.6.1Counter ..................................... 60
2.6.2InputCapture .................................. 62
2.6.3OutputCompare ................................ 65
2.6.4PulseWidthModulation ............................ 65
2.6.5Exercises .................................... 66
2.7OtherFeatures ...................................... 68
2.7.1WatchdogTimer ................................ 68
i
2.7.2PowerConsumptionandSleep ......................... 69
2.7.3Reset ...................................... 70
2.7.4Exercises .................................... 71
3CommunicationInterfaces 73
3.1SCI(UART) ....................................... 75
3.2SPI ............................................ 82
3.3IIC(I 2 C) ........................................ 83
3.3.1DataTransmission ............................... 84
3.3.2SpeedControlThroughSlave ......................... 87
3.3.3Multi-MasterMode ............................... 87
3.3.4ExtendedAddresses .............................. 88
3.4Exercises ........................................ 88
4SoftwareDevelopment 89
4.1DevelopmentCycle ................................... 91
4.1.1DesignPhase .................................. 91
4.1.2Implementation ................................. 92
4.1.3Testing&Debugging .............................. 94
4.2Programming ...................................... 97
4.2.1AssemblyLanguageProgramming ....................... 97
4.3Download ........................................117
4.3.1ProgrammingInterfaces ............................117
4.3.2Bootloader ...................................118
4.3.3FileFormats ..................................118
4.4Debugging ........................................121
4.4.1NoDebugger ..................................121
4.4.2ROMMonitor .................................124
4.4.3InstructionSetSimulator ............................124
4.4.4In-CircuitEmulator ...............................125
4.4.5DebuggingInterfaces ..............................125
4.5Exercises ........................................127
5Hardware 129
5.1Switch/Button ......................................129
5.2MatrixKeypad .....................................130
5.3Potentiometer ......................................132
5.4Phototransistor .....................................132
5.5PositionEncoder ....................................133
5.6LED ...........................................134
5.7NumericDisplay ....................................135
5.8MultiplexedDisplay ..................................136
5.9SwitchingLoads ....................................138
5.10Motors ..........................................140
5.10.1BasicPrinciplesofOperation .........................140
5.10.2DCMotor ....................................142
5.10.3StepperMotor .................................146
5.11Exercises ........................................153
ii
ATableofAcronyms
155
Index
159
iii
iv
Zgłoś jeśli naruszono regulamin