Versuch mal sowas:
Code:#include <avr/io.h> #include <avr/interrupt.h> #include <avr/signal.h> volatile uint8_t count; 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++) send_char(*s); } void init_timer0() { TCCR0 = (1<<CS01) | (1<<CS00); //Vorteiler 64 TIMSK |= (1<<TOIE0); } void waitms (uint16_t s) { while (s--) { uint16_t cnt; cli(); count = 0; TCNT0 = 6; do { cli(); cnt = count; sei(); } while (cnt < 1000); } } SIGNAL (SIG_OVERFLOW0) { TCNT0 = 6; count++; } char a[] = "108:158#13#10"; int main(void) { init_usart(); init_timer0(); sei(); while (1) { send_string (a); waitms (1000); } }
Lesezeichen