Praksismik 02 14s17017
Praksismik 02 14s17017
Abstrak
Practicum module 1 microprocessor system practicum will discuss more about the components of the input
output base on the ATMega 8535 board. Practice it learn how to port to make as input or output. The input
output application will be made by using WinAVR software in C. Besides practicum also aims to understand Ude
settings related to large uses and crystal types.
--Bit 5:4 – COM01:0: Compare Match Output Mode --Timer/Counter Register – TCNT0
These bits control the Output Compare pin (OC0)
behavior. If one or both of the COM01: 0 bit are set,
the OC0 output overrides the normal port
functionality of the I.O pin it is connected to.
However, note that the Data Direction Register
(DDR) bit corresponding to the 0Co pin must be set The Timer/Counter Register gives direct access, both
in order to enable the output driver. When OC0 is for read and write operations, to the Timer/Counter
connected to the pin, the function of the COM01:0 unit 8-bit counter. Writing to the TCNt0 Register
block (removes) the Compare Match on the one to the flag. When the I-bit in SREG, OCIE0
following timer clock. Modifying the counter (TCNT0) (Timer/Counter0 Compare Match Interrupt is
while the counter is running, introduces a risk of executed.
missing a Compare between TCNT0 and the OCR0
Register.
>>>Bit 0 – TOV0: Timer/Counter 0 Overflow
--.Output Compare Register – OCR0
Flag The bit TOV0 is set (one) when an overflow
occurs in Timer/Counter0. TOV0 is cleared by
hardware when executing the corresponding
interrupt handling vector. Alternatively, TOV0 is
The Output Compare Register contains an 8 bit value cleared by writing a logic one to the flag. When
that is continuously compared with the counter the SREG I-bit, TOIE0 (Timer/Counter0 Overflow
value (TCNT0). A match can be used to generate an Interrupt is executed. In phase correct PWM
output compare interrupt, or to generate a mode, this bit is set when Timer/Counter0
waveform output on the OC0 pin changes counting direction at 0x00.
PB.0
1
Void main()
{
DDRB=0×FF;
PB.1
2
#include <mega8535.h>
PORTB=0b10101010;
While (1)
}
{
TCCR0=0b101;
TCNT0=125;
E
53642m
N
O
H
JM
A
X
D
,7
PROSEDUR PERCOBAAN
PB.2 PB.3
3
Tabel 1.
4
While((TIFR &0b00000001)==0);
TCCR0=0;
TIFR=0b00000001;
PORTB= ̴ PORTB;
}
Program1.
PB.4
5
PB.5
6
2
1
3
4
5
6
PB.6
7
}
T=
CN11
Tabel
1
fclc
Rumus 1.
2.
1
× ( FFh+1 ) × N
#include <mega8535.h>
Void main()
{
DDRB=0×FF;
While (1)
{
TCNT1=49910;
TCCR0=0b101;
PB.2
3
PB.3
4
While((TIFR &0b00000100)==0);
TCCR1B=0;
TIFR=0b00000100;
PORTB= ̴ PORTB;
}
Program 2.
PB.4
5
PB.5
6
PB.6
7
2
PB.7
8
u3)L
flJprB
yshgoM
detik.anm
Char str[10];
Void main()
{
DDRB=0×FF;
PORTB.0=1;
Lcd_init(16);
Lcd_clear();
b(S
D
421
3.3 External Clock Sebagai Counter
#include <mega8535.h>
#include <alcd.h>
#include <stdio.h>
Lcd_putsf(“Counter 0=”);
TCCR0=0b110;
While (1)
{
Sprint(str,”%i”, TCNT0);
Lcd_gotoxy(10,0);
Lcd_puts(str);
}
}
Program 3.
IV.
4.1.1 Percobaan 1.
HASIL ANALISIS
#include <mega8535.h>
Void main()
2
1
3
4
{
DDRB=0×FF;
PORTB=0b10101010;
While (1)
T=
T=
T=
}
{
1
TCCR0=0b101;
TCNT0=125;
While((TIFR &0b00000001)==0);
TCCR0=0;
TIFR=0b00000001;
PORTB= ̴ PORTB;
}
fclc
× ( FFh+1 ) × N
1
16.000.000
1
16.000.000
T= 0,000007875
4.1.2
void main()
{
DDRB = 0xFF;
× ( 125+1 ) ×1
× ( 126 )
#include <mega8535.h>
PORTB = 0b10101010;
while (1)
{
}
TCCR0 = 0b101;
TCNT0 = 112;
while ((TIFR & 0b00000001) ==0);
TCCR0 = 0;
TIFR = 0B00000001;
PORTB = ~PORTB ;
T=
T=
1
f clc
× ( FFh+1 ) × N
1
16.000.000
1
16.000.000
T= 0,0000070625
× ( 112+1 ) ×1
× ( 113 )
4.2.1 Percobaan 1 Modifikasi. b. AVR GCC memiliki syntax delay untuk
#include <mega8535.h> membantu pemrogra man yang
membutuhkan fungsi waktu.
Void main() c. Untuk membuat port berfungsi sebagai
{ input dengan cara mengeset DDRx nya
dengan 0x00 (semua pin jadi pin input).
DDRB=0×FF;
Swi tch digunakan sebagai input dari user
While (1)
di Port D.
{ d. Dalam membuat port berfungsi sebagai
TCNT1=49910; output dengan cara mengeset DDRx nya
TCCR0=0b101; den gan 0xFF (semua pin jadi pin output).
While((TIFR &0b00000100)==0); LED digunakan sebagai output di Port A.
TCCR1B=0; e. Keselahan pada penempatan pin akan
TIFR=0b00000100; berdapak pada lampu LED yang akan
menyala/mati.
PORTB= ̴ PORTB; f. Kabel jumper yang dipasang pada ATMega
} harus sesuai dengan urutan jika salah
} maka lampu LED yang diinginkan
menyala/mati tidak sesuai dengan yang
diinginkan.
g. Ketepatan dan ketelitian dalam membuat
4.2.2
code program sangat berpengaruh pada
output yang keluar.
4.3.1 Percobaan 3. h. Pada praktikum modul 1 ini kami hanya
#include <mega8535.h> berhasil menyelesaikan percobaan sampai
#include <alcd.h> 1C.1 dimana keterbatasan waktu yang
#include <stdio.h> tersedia saat praktikum. Dan melanjutkan
Char str[10]; mengerjakan percobaan 1C.2 diluar sesi
Void main() praktikum.
{
DDRB=0×FF;
PORTB.0=1; DAFTAR PUSTAKA
Lcd_init(16);
Lcd_clear(); [1]. Kadir, Abdul (2012). Buku Pintar
Lcd_putsf(“Counter 0=”); MATLABuntuk Pemula. Yogyakarta : MediaKom.
TCCR0=0b110;
While (1) [2]. Utami, Ema. dan Sukrisno (2005). 10
{ Langkah Belajar Logika dan Algoritma
Sprint(str,”%i”, TCNT0); Menggunakan MATLAB di GNU/Linux.
Lcd_gotoxy(10,0); Yogyakarta : Andi Offset
Lcd_puts(str);
} [3]. Jackstar H. S., Panduan Penulisan Laporan,
} Jacks Publishing, Bandung, 2008.
LAMPIRAN
1. Tugas 1
#include <mega8535.h>
V. KESIMPULAN
Void main()
Adapun kesimpulan yang dapat diambil dai {
praktikum ini adalah sebagai berikut : DDRB=0×FF;
a. Sebelum melakukan praktikum sebaiknya PORTB=0b10101010;
baca petunjuk buku panduan mengenai While (1)
ATMega dan juga modul yang tersedia {
TCCR0=0b101; }
TCNT0=125; }
While((TIFR &0b00000001)==0);
TCCR0=0;
TIFR=0b00000001;
PORTB= ̴ PORTB;
}
}
Tugas 2
#include <mega8535.h>
Void main()
{
DDRB=0×FF;
While (1)
{
TCNT1=49910;
TCCR0=0b101;
While((TIFR &0b00000100)==0);
TCCR1B=0;
TIFR=0b00000100;
PORTB= ̴ PORTB;
}
}
Tugas 3.
#include <mega8535.h>
#include <alcd.h>
#include <stdio.h>
Char str[10];
Void main()
{
DDRB=0×FF;
PORTB.0=1;
Lcd_init(16);
Lcd_clear();
Lcd_putsf(“Counter 0=”);
While (1)
{
Sprint(str,”%i”, TCNT0);
Lcd_gotoxy(10,0);
Lcd_puts(str);