Danke, aber warum funktioniert das hier dann nicht:
Code:
#define F_CPU 8000000
#define BAUD_RATE 9600
#include <avr/delay.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <avr/io.h>
#include <avr/sfr_defs.h>
// -- METHOD DECLARATIONS
int putChar(char c);
void uart_init(int tx, int rx);
uint8_t uart_readChar(void);
int main (void) {
//GLOBAL INTERRUPT ENABLE
sei();
//RX COMPLETE INTERRUPT ENABLE
UCSRB |= (1<<RXCIE);
//UART AN
uart_init(1, 1);
//PRINTF FÜR AUSGABE KONFIGURIEREN
fdevopen(putChar,NULL,0);
while(1)
{
}
return 0;
}
SIGNAL(SIG_UART0_RECV) {
printf("HALLO");
}
// -- UART METHODS
void uart_init(int tx, int rx) {
UBRRL = (F_CPU/(BAUD_RATE*16l)-1);
if(tx == 1) {
UCSRB |= (1<<TXEN);
}
if(rx == 1) {
UCSRB |= (1<<RXEN);
}
}
int putChar(char c){
while ( !( UCSRA & (1<<UDRE)) );
UDR=c;
return 0;
}
uint8_t uart_readChar(void) {
loop_until_bit_is_set(UCSRA, RXC);
return UDR;
}
Meiner Meinung nach sollte ich bei minicom irgendeiner Taste drücken können und dann sollte der Controller "HALLO" zum PC senden. Warum tut er das nicht?
mfg
jagdfalke
Lesezeichen