You are on page 1of 18

Microcontroller

Fundamentals
B. Furman
07SEP2010
Learning Objectives
Explain the general architecture of a
microcontroller
List the key features of the ATmega16
microcontroller
Explain the features and elements on the
STK500
Explain how the switches and LEDs on the
STK500 are driven
Explain the concepts of microcontroller pins as
inputs and outputs
Convert between binary and hexadecimal digits
Microcomputer Architecture
http://www.engr.colostate.edu/~dga/mechatronics/figures/7-1.gif
CPU
Components of a Microcontroller
http://www.engr.colostate.edu/~dga/mechatronics/figures/7-2.gif
ATmega16 Microcontroller
Pin number
Pin name
Special function
Source: http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf
Note the
limitations!
p. 291
Atmel STK500
Source: http://www.rfsource.gr/product/micro/STK500/stk500_en.htm
Universal Evaluation Board for Atmel AVR Microcontrollers
Momentary
switches
(8 ea.)
LED (8 ea.)
Ports A-E
header pins
Primary
RS-232
LED
header pins
Spare
RS-232
switch
header pins
STK500 LED
Source: http://www.atmel.com/dyn/resources/prod_documents/doc1925.pdf
+5V
PORT header pins on the STK500
ATmega16
pins come
out to
header
pins
+5V
ATmega16
PORTx header pin
Need to jumper pin header to LEDs
You will
add a
jumper
wire to
connect
header pin
to LED
pins
+5V
jumper wire
ATmega16
PORTx header pin
LEDn header pin
Turning off an LED on the STK500
Writing bits
to the
PORTx
register will
affect the
voltage on
the pins:
A 1 puts
V
TG
(=5V)
on the pin
LED is
OFF
+5V
jumper wire
PORTx register
ATmega16
PORTx header pin
LEDn header pin
V
TG
= +5V
0
1
Off
Turning on an LED on the STK500
Writing bits
to the
PORTx
register will
affect the
voltage on
the pins:
A 0 puts
GND on the
pin
LED is ON
+5V
jumper wire
PORTx register
ATmega16
PORTx header pin
LEDn header pin
V
TG
= +5V
0
1
On
STK500 Switch
Source: http://www.atmel.com/dyn/resources/prod_documents/doc1925.pdf
Binary and Hexadecimal Numbers - 1
Microcontrollers are fundamentally digital
(as opposed to analog) and use binary
logic
Two states: high and low, 1 or 0, on or off
Often 5V or 0V
One binary digit is called a bit
It can take on two possible states: 1 or 0
Eight binary digits is called a byte
Four binary digits is called a nibble
Binary and Hexadecimal Numbers - 2
1 1 0 0 1 1 0 1
7 6 5 4 3 2 1 0
Bit No.
Lower nibble
(4 bits)
Upper nibble
(4 bits)
LSB
(Least Significant Bit)
MSB
(Most Significant Bit)
Binary and Hexadecimal Numbers - 3
1 1 3 8
Base 10
1138 8 30 100 1000
10 8 10 3 10 1 10 1
0 1 2 3
= + + +
+ + +
1 1 0 1
Base 2
13 1 0 4 8
2 1 2 0 2 1 2 1
0 1 2 3
= + + +
+ + +
Base 10
Place Value
Question: What is the MAXIMUM value (base 10 decimal) that can be represented by 4 bits?
Binary and Hexadecimal Numbers - 4
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
1 0 0 0 8
1 0 0 1 9
1 0 1 0 A
1 0 1 1 B
1 1 0 0 C
1 1 0 1 D
1 1 1 0 E
1 1 1 1 F
HEX Binary Decimal
Fill out the table
Practice
0xFF in binary
0x0A in binary
0xD5 in binary
0x1B in decimal
Binary and Hexadecimal Numbers - 5
0 0 0 0
0
0
0 0 0 1
1
1
0 0 1 0
2
2
0 0 1 1
3
3
0 1 0 0
4
4
0 1 0 1
5
5
0 1 1 0
6
6
0 1 1 1
7
7
1 0 0 0
8
8
1 0 0 1
9
9
1 0 1 0
10
A
1 0 1 1
11
B
1 1 0 0
12
C
1 1 0 1
13
D
1 1 1 0
14
E
1 1 1 1
15
F
HEX Binary Decimal
Fill out the table
Practice
0xFF in binary
1 1 1 1|1 1 1 1
0x0A in binary
0 0 0 0|1 0 1 0
0xD5 in binary
1 1 0 1|0 1 0 1
0x1B in decimal
1x2
4
+ 1x2
3
+0x2
2
+1x2
1
+1x2
0
=27
Binary and Hexadecimal Numbers - 6
0 0 0 0
0
0
0 0 0 1
1
1
0 0 1 0
2
2
0 0 1 1
3
3
0 1 0 0
4
4
0 1 0 1
5
5
0 1 1 0
6
6
0 1 1 1
7
7
1 0 0 0
8
8
1 0 0 1
9
9
1 0 1 0
10
A
1 0 1 1
11
B
1 1 0 0
12
C
1 1 0 1
13
D
1 1 1 0
14
E
1 1 1 1
15
F
HEX Binary Decimal
10 bits can represent how
many different items?

You might also like