Professional Documents
Culture Documents
Mikroprosesor II
Sistem Mikroprosesor II
Deskripsi :
Mata kuliah ini mempelajari tentang arsitektur
mikrokontroler AVR ATmega16 , pemrograman
mikrokontroler berbasis bahasa C (Codevision
AVR + Proteus), pemahaman antar muka dan
projek sederhana berbasis ATMega16
Sistem Mikroprosesor II
Kompetensi :
Mahasiswa paham tentang sistem
mikrokontroler ATMega16 dan
pemrogramannya berbasis bahasa C serta
mampu menganalisa dan membuat sistem
aplikasi mikrokontroler sederhana.
Sumber belajar :
Atmel AVR Microcontroller Primer: Programming and
Bobot Penilaian
No Jenis penilaian
1
2
3
4
Tugas
Partisipasi
individu
UTS
UAS
Skor
maksimum
25 %
10 %
30 %
35 %
Ketentuan Penilaian
Tugas harus dilengkapi sebelum perkuliahan
Materi
Arsitektur ATMega16
Pemrograman C
Pengenalan Codevision & Proteus
Input output
Interupt
ADC
Timer dan Counter
LCD
Aplikasi Kendali Motor
TERMINOLOGY
Microcontroller vs. Microprocessor vs. Microcomputer
A microprocessor is a central processing unit on a
single chip.
A microprocessor combined with support circuitry ,
peripheral I/O components and memory (RAM & ROM)
used to be called a microcomputer.
A microprocessor where all the components mentioned
above are combined on the same single chip that the
microprocessor is on, is called a microcontroller.
We will be using the ATMEGA 16 microcontroller.
Microcontrollers
A
microcontroller
interfaces to
external devices
with a minimum
of external
components
MICRCONTROLLER ARCHITECTURE
1: CPU -- fetches the instructions stored in the program memory,
decodes them, and executes them. The CPU itself is composed of
registers the arithmetic logic unit, the instruction decoder
and control circuitry.
2: PROGRAM MEMORY: The program memory stores the
instructions that form the program. To accommodate larger
programs, the program memory may be partitioned as internal
program memory and external program memory (in some
controllers). Program memory is usually nonvolatile and is of
EEPROM, EPROM, Flash, or OTP (one-time programmable) type.
[EEPROM for Atmega8].
3: RAM: The RAM is the data memory of the controller. The CPU
uses RAM to store variables as well as the stack. The stack is used
by the CPU to store return addresses from where to resume
execution after it has completed a subroutine or an interrupt call.
MICRCONTROLLER ARCHITECTURE
CLOCK OSCILLATOR: The controller executes the program out of the
program memory at a certain rate. This rate is determined by the
frequency of the clock oscillator. The clock oscillator could be an
internal RC-oscillator [this is the case for the Atmega 8], or an
oscillator with an external timing element, such as a quartz crystal or
RC circuit. As soon as power is applied to the controller, the oscillator
starts operating.
5: RESET AND BROWNOUT DETECTOR CIRCUIT: The reset circuit in
the controller ensures that at startup all the components and
control circuits in the controller start at a predefined initial
state and all the required registers are initialized properly.
4:
MICRCONTROLLER ARCHITECTURE
SERIAL PORT: The serial port can operate at any required data transfer
speed. The serial port takes data bytes from the controller and shifts out the
data one bit at a time to the output. Similarly, it accepts external data a bit
at a time, makes a byte out of 8 such bits, and presents this to the controller.
7: DIGITAL I/O PORT: The microcontroller uses the digital I/O components to
exchange digital data with the outside world. Compared to the serial port,
which transfers data a bit at a time, the data from the I/O port is
exchanged as bytes.
8: ANALOG I/O PORT: Analog input is performed using an analog-to-digital
converter (ADC). The controller could be equipped with an integrated ADC or
an analog comparator [the Atmega 8 has both (?)] , which is used under
software control to perform A-to-D conversion. ADCs are used to acquire
senor data from devices such as temperature sensors and photocells. Such
sensors often produce proportional analog voltage data.
Analog output is performed using a digital-to-analog converter (DAC) [must
be externally in case of Atmega 8].
6:
Most controllers are equipped with pulse-width modulators that can be used to get
analog voltage with a suitable external RC filter [this is the case for the Atmega8].
DACs are used to drive motors, to generate sound, for visual displays.. (dimming
LEDs).
[SENSORS assignment].
MICRCONTROLLER ARCHITECTURE
9:
Alur pemrograman
Proteus ISIS
Used in Lab
19
AVR Architecture
What are the features of RISC?
1 instruction per clock cycle (pipelined)
Lots of registers: 32 GP registers
Register-to-register operation
Variations in the parts:
TINY to MEGA
ATtiny10
Processor has only 8 pins
ATmega128 (128K bytes flash)
Processor has 64 pins
20
AVR Architecture
21
22
On Chip
Debugger
24
25
26
27
28
29
30
Program Flash
Vectors, Code, and
(Unchangeable) Constant Data
Working Registers
Includes X, Y, and Z registers.
I/O Register Space
Includes named registers
SRAM Data Space
Runtime Variables and Data
Stack space
EEPROM space
For non-volatile but alterable data
31
32
33
34
I/O Direct
35
Data Direct
36
Data Indirect
37
38
39
40
41
42
AVR Timer/Counter 0
8 Bit
Wrap-Around
Up Counter
Interrupt on
overflow
44
AVR Timer/Counter 0
8 Bit Up Counter
counts from 0 to 255 (0xFF), then loops
to 0
Internal or External Clock source
Prescaler
Output capture through OC0, i.e. PB3, pin
4
Interrupt on Overflow
Transition from 255 to 0 can trigger
interrupt if
45
AVR Timer/Counter 0
OC0, Output Compare Match output:
Whenever TCNT0 equals OCR0 (Output
Compare Register 0), the comparator
signals a match
The PB3 pin can serve as an external
output for the Timer/Counter0 Compare
Match. The PB3 pin has to be configured
as an output
46
AVR Timer/Counter 1
16 Bit
Dual Comparators A,B (output captures)
Up Counter
Interrupt on:
Overflow
Compare A/B
Input Capture of external event on ICP
pin.
Can also act as an 8, 9 or 10 bit PWM UpDown Counter.
47
AVR Timer/Counter 1
The Input Capture unit of Timer/Counter
captures external events and gives them a
time-stamp indicating time of occurrence.
The external signal indicating an event, or
multiple
events, can be applied via the ICP1 pin or
alternatively, via the Analog Comparator unit.
The time-stamps can then be used to calculate
frequency, duty-cycle, and other features of the
signal applied.
Alternatively the time-stamps can be used for
creating a log of the events.
48
50
51
52
Interrupts
Interrupts halt normal code execution in order to
go do something more important or time sensitive
Interrupt Handlers
Using the Interrupt Vectors
Interrupts are used for:
RESET
Timers and Time-Critical Code
Hardware signaling
Im done
Somethings happened that you want to
know
about
I have something for you
53
54
55
Reading Assignment:
Chapter 1 of Embedded C Programming and the Atmel AVR
56