Hanya sekedar sharing pengetahuan kalau ada salah kata benahi sendiri. Silahkan cek koleksi kaos polos di www.facebooj.com/DunaiPolos

Thursday, 10 April 2014

Program Interrupt Output LCD

kali ini ingin berbagi tentang program dari AVR CodeVision
dengan input tombol yang tehubung pada interrupt dan keluaran pada tampilan LCD di PORTC,
semua interrupt disetting mode Falling Edge. tampa panjang lebar ini programnya......

#include <mega8535.h>
#include <delay.h>

// Alphanumeric LCD functions
#include <alcd.h>



// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
// Place your code here
        lcd_clear();
        lcd_gotoxy(0,0);
        lcd_putsf("DENGARKAN  SUARA");
        lcd_gotoxy(3,1);
        lcd_putsf("ADZAN  !!!");                  // program tombol 1    
}

// External Interrupt 1 service routine
interrupt [EXT_INT1] void ext_int1_isr(void)
{
// Place your code here
        lcd_clear();
        lcd_gotoxy(2,0);
        lcd_putsf("Waktu Sholat");
        lcd_gotoxy(0,1);
        lcd_putsf("01:00 Menit Lagi");
        delay_ms(100);              
}

// External Interrupt 2 service routine
interrupt [EXT_INT2] void ext_int2_isr(void)
{
// Place your code here
        lcd_clear();
        lcd_gotoxy(0,0);
        lcd_putsf("Lurus & Rapatkan");
        lcd_gotoxy(2,1);
        lcd_putsf("Shof Sholat");                  // program tombol 3
}

// Declare your global variables here

void main(void)
{
// Declare your local variables here

// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;

// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;

// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;

// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;

TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: On
// INT0 Mode: Falling Edge
// INT1: On
// INT1 Mode: Falling Edge
// INT2: On
// INT2 Mode: Falling Edge
GICR|=0xE0;
MCUCR=0x0A;
MCUCSR=0x00;
GIFR=0xE0;

TIMSK=0x00;

UCSRB=0x00;

ACSR=0x80;
SFIOR=0x00;

ADCSRA=0x00;

SPCR=0x00;

TWCR=0x00;

// Characters/line: 40
lcd_init(40);

// Global enable interrupts
#asm("sei")

while (1)
      {
      // Place your code here

      }
}