REFERENSI
[1] Electrical Engineering IT Del,2015, “Modul Praktikum
Sistem Mikroprosesor”,Laguboti
[2] Adel S. Sedra and Kennet C. Smith, Microelectronic
Circuits, Oxford University Press, USA, 2004.
[3] Mervin T Hutabarat, Praktikum Sistem Mikroprosesor
Laboratorium Dasar Teknik Elektro ITB,Bandung, 2015.
LAMPIRAN
1. Tugas II.A.1
Code Program
#include <mega8535.h>
void main()
{
DDRB = 0xFF;
while(1)
{
TCNT1 = 49910;
TCCR1B = 0b101;
while((TIFR & 0b00000100) == 0);
TCCR1B = 0;
TIFR = 0b00000100;
PORTB = ~PORTB;
}
}
Hasil Percobaan :
2. Tugas II.A.2
Code Program
#include <mega8535.h>
void main()
{
DDRB = 0xFF;
while(1)
{
TCNT1 = 34286; TCCR1B = 0b101;
while((TIFR & 0b00000100) == 0); TCCR1B = 0;
TIFR = 0b00000100; PORTB = ~PORTB;
}
}
3. Tugas II.B.1
Code Program
#include <mega8535.h>
#include <alcd.h>
#include <stdio.h>
char str[10];
void main()
{
DDRB.0 = 0; PORTB.0 = 1; lcd_init(16); lcd_clear();
lcd_putsf("Counter 0= "); TCCR0 = 0b110;
while(1)
{ sprintf(str,"%i",TCNT0); lcd_gotoxy(10,0);
lcd_puts(str);
}
}
Hasil percobaan :
4. Tugas II.B.2
Code Program
#include <mega8535.h>
#include <alcd.h>
#include <stdio.h>
#include <delay.h>
char str[10];
void main()
{
unsigned int i; DDRB.0 = 0; PORTB.0 = 1; DDRA = 0xFF; lcd_init(16); lcd_clear();
lcd_putsf("Counter 0= "); TCCR0 = 0b110;
while(1)
{
sprintf(str,"%i",TCNT0); lcd_gotoxy(10,0); lcd_puts(str);
i = TCNT0; PORTA = 0xFF; delay_ms(i*1000); PORTA = 0x00; delay_ms(i*1000);
}
}
Hasil percobaan :
5. Tugas II.C.1
#include <mega8535.h>
#include <alcd.h>
void main()
{
DDRD.2 = 0; DDRD.3 = 0; PORTD.2 = 1; PORTD.3 = 1;
GICR = 0b11000000; MCUCR = 0b00000000;
#asm("sei") lcd_init(16); lcd_clear();
lcd_putsf("EXT Iterrupt");
while(1);
}
interrupt[2]void interupsi_ext0(void)
{ lcd_gotoxy(0,1); lcd_putsf("INT Ext 0");
}
Hasil percobaan :
interrupt[3]void interupsi_ext1(void)
{ lcd_gotoxy(0,1); lcd_putsf("INT Ext 1");
}