Hallo,
danke für eure Hilfe, ich habs jetzt so gelöst:
Code:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
volatile uint8_t count = 0;
void init_usart(void)
{
UBRRL |= 0b01100111;
UCSRB = (1<<TXEN) | (1<<RXEN);
UCSRC = (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0);
}
void send_char(unsigned char s)
{
while (!(UCSRA & (1<<UDRE)));
UDR = s;
}
void send_string(char *s)
{
while(*s != '\0')
{
send_char(*s);
s++;
}
}
void waitms(uint16_t s)
{
uint16_t i;
uint8_t j;
TCCR0 |= (1<<CS01) | (1<<CS00); //Vorteiler 64
TIMSK |= (1<<TOIE0);
for(i=0;i<s;i++)
{
count = 0;
TCNT0 = 6; // Timer auf 6 vorladen, da (16000000/64)^-1 = 0.000004s
while(count != 1)
{}
} // -> 1ms = 0.000004s*250
TIMSK |= (0<<TOIE0);
}
SIGNAL(SIG_OVERFLOW0)
{
count = 1;
}
int main(void)
{
sei();
unsigned int i;
char a = "Hallo Welt";
i = 0;
init_usart();
do
{
send_string(a);
waitms(1000);
}
while (i == 0);
}
Gruß
Spurius
Lesezeichen