This textbook provides practicing scientists and engineers a primer on the Atmel AVR microcontroller. Our approach is to provide the fundamental skills to quickly get up and operating with this internationally popular microcontroller. The Atmel ATmega16 is used as a representative sample of the AVR line. The knowledge you gain on the ATmega16 can be easily translated to every other microcontroller in the AVR line. We cover the main subsystems aboard the ATmega16, providing a short theory section followed by a description of the related microcontroller subsystem with accompanying hardware and software to exercise the subsytem. In all examples, we use the C programming language. We conclude with a detailed chapter describing how to interface the microcontroller to a wide variety of input and output devices.
Author(s): Steven F. Barrett, Daniel Pack, Mitchell Thornton
Series: Synthesis Lectures on Digital Circuits and Systems
Edition: 1
Publisher: Morgan & Claypool Publishers
Year: 2007
Language: English
Pages: 188
Atmel AVR Microcontroller Primer: Programming and Interfacing......Page 1
Acknowledgments......Page 5
Reduced Instruction Set Computer......Page 13
Assembly Language Instruction Set......Page 14
In-System Programmable Flash EEPROM......Page 15
Programmable Lock Bits......Page 17
PORT SYSTEM......Page 18
Time Base......Page 20
Serial USART......Page 21
Analog-to-Digital Converter......Page 22
Power Consumption......Page 23
Hardware Configuration......Page 25
Software Configuration......Page 27
PROGRAMMING THE ATmega16......Page 31
Programming Procedure......Page 32
SOFTWARE PORTABILITY......Page 34
CHAPTER PROBLEMS......Page 35
SERIAL COMMUNICATION TERMINOLOGY......Page 36
Nonreturn to Zero Coding Format......Page 37
SERIAL USART......Page 38
System Overview......Page 39
USART Clock Generator......Page 40
USART Registers......Page 41
System Operation and Programming......Page 43
SPI Operation......Page 45
Registers......Page 46
Programming......Page 48
REFERENCES AND FURTHER READING......Page 49
CHAPTER PROBLEMS......Page 50
BACKGROUND THEORY......Page 51
Analog versus Digital Signals......Page 52
Sampling, Quantization, and Encoding......Page 54
Resolution and Data Rate......Page 58
ANALOG-TO-DIGITAL CONVERSION PROCESS......Page 60
Successive Approximation......Page 63
THE ATMEL ATmega16 ADC SYSTEM......Page 65
Block Diagram......Page 66
ADC Multiplexer Selection Register......Page 68
Programming the ADC......Page 69
Digital-to-Analog Conversion......Page 72
REFERENCES AND FURTHER READING......Page 73
CHAPTER PROBLEMS......Page 74
ATmega16 INTERRUPT SYSTEM......Page 75
PROGRAMMING AN INTERRUPT......Page 76
External Interrupts......Page 78
Internal Interrupt......Page 81
CHAPTER PROBLEMS......Page 84
OVERVIEW......Page 85
TIMING SYSTEM OVERVIEW......Page 86
Input Capture---Measuring External Timing Event......Page 89
Output Compare---Generating Timing Signals to Interface External Devices......Page 91
Industrial Implementation Case Study (PWM)......Page 92
OVERVIEW OF THE ATMEL TIMERS......Page 93
TIMER 0 SYSTEM......Page 94
Modes of Operation......Page 96
Timer 0 Registers......Page 97
Output Compare Register......Page 98
Timer/Counter Interrupt Mask Register......Page 100
Timer/Counter Register 1 (TCNT1H/TCNT1)......Page 101
Timer/Counter Control Register 2......Page 104
Output Compare Register (OCR2)......Page 105
PROGRAMMING THE TIMER SYSTEM......Page 106
Precision Delay......Page 108
Pulse Width Modulation......Page 109
Input Capture Mode......Page 111
REFERENCES AND FURTHER READING......Page 113
CHAPTER PROBLEMS......Page 114
Atmel AVR Operating Parameters and Interfacing......Page 115
OPERATING PARAMETERS......Page 116
INPUT DEVICES......Page 117
Switches......Page 119
Switch Debouncing......Page 120
Digital Sensors......Page 121
OUTPUT DEVICES......Page 124
Light-Emitting Diodes......Page 125
Tristate LED Indicator......Page 127
Liquid Crystal Display......Page 130
High-Power DC Devices......Page 134
DC MOTOR SPEED AND DIRECTION CONTROL......Page 135
AC Devices......Page 136
APPLICATION: FLIGHT SIMULATOR PANEL......Page 137
SUMMARY......Page 167
CHAPTER PROBLEMS......Page 168
ATmega16 Register Set......Page 169
ATmega16 Header File......Page 171
Author Biography......Page 186
Index......Page 187