arkadaşlar atmega8 ile denemeler yapıyorum seri iletişime kadar bir şeyler yaptım
aşagıdaki örneği netden buldum biraz değiştirip int0 kesmesinde pc'ye merhaba göndermek istiyorum
seri iletişim konusunda biraz yardım ve yönlendirme yapmanızı rica edecektim
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h> //standart giris cikis
#include<avr\interrupt.h>
ISR(INT0_vect) //int0 harici kesme
{
PORTB|= _BV(0);
}
int UartPutChar(char c,FILE* stream);
int UartGetChar(FILE* stream); //uartstr adli degiskene yazilan her deger RS232'ye
//gider, ve RS232'den gelen deger bu degiskene yazilir
FILE uartstr = FDEV_SETUP_STREAM(UartPutChar, UartGetChar, _FDEV_SETUP_RW);
int UartPutChar(char c,FILE* stream) { //RS232 ye bir karakter gonderir
loop_until_bit_is_set(UCSRA, UDRE);
UDR = c;
return 0;
}
int UartGetChar(FILE* stream) { //RS232'den bir karakter okur
char c;
loop_until_bit_is_set(UCSRA,RXC);
c = UDR;
return c;
}
void mcu_init(void){ // USART kurulumu
// 8 Data, 1 Stop, No Parity
//Baud rate: UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x0C;
DDRB = 0xff; // PortB çıkış
PORTB = 0x00; // portu temizle
DDRD = 0B00000010; // port D giriş tx için 2 pin çıkış
PORTD = 0x00; // portu temizle
}
//Ana Program Fonksiyonu
int main(void){
char ad[12];
mcu_init(); //islemciyi hazirla
GICR = (1<<INT0); //int0 ve int1 kesmesi aktif
MCUCR = (1<<ISC00)|(1<<ISC01); // int 0ve 1 yukselen kenar
sei(); // enable interrupts
//stdout=stdin=&uartstr; //standart girdi ve ciktiyi uartstr degiskenine yonlendir
while(1){ //sonsuz dongu
}
}