fork download
  1. #include <stdio.h>
  2. #include <avr/io.h>
  3. #include <util/delay.h>
  4. #include <util/setbaud.h>
  5.  
  6. #undef BAUD
  7. #define BAUD 9600
  8. #define BAUD_PRESCALE (((F_CPU/(BAUD*16UL)))-1)
  9.  
  10. static void uart_init(unsigned int ubrr) {
  11. UBRR0H = (unsigned char)(ubrr>>8);
  12. UBRR0L = (unsigned char)(ubrr);
  13.  
  14. UCSR0B = (1<<RXEN0)|(1<<TXEN0);
  15.  
  16. // frame format: 8data, 2stop bit, no parity
  17. UCSR0C = (1<<USBS0)|(3<<UCSZ00);
  18. }
  19.  
  20. static void USART_Transmit(unsigned char data) {
  21. PORTB ^= (1<<PB1);
  22. loop_until_bit_is_set(UCSR0A, UDRE0);
  23. UDR0 = data;
  24. }
  25.  
  26.  
  27. int main(void) {
  28. uart_init(BAUD_PRESCALE);
  29.  
  30. while (1) {
  31. unsigned char c = 0b11000001;
  32. USART_Transmit(c);
  33. _delay_ms(1000);
  34. }
  35.  
  36. return 0;
  37. }
  38.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:2:20: fatal error: avr/io.h: No such file or directory
 #include <avr/io.h>
                    ^
compilation terminated.
stdout
Standard output is empty