fork download
  1. Richards-MacBook-Pro:src richard$ cat main.c
  2. /*
  3. * Hackaday.com AVR Tutorial firmware
  4. * written by: Mike Szczys (@szczys)
  5. * 10/24/2010
  6. *
  7. * ATmega168
  8. * Blinks one LED conneced to PD0
  9. *
  10. * http://h...content-available-to-author-only...y.com/2010/10/25/avr-programming-02-the-hardware/
  11. */
  12.  
  13. #include <avr/io.h>
  14. #include <avr/interrupt.h>
  15.  
  16. int main(void)
  17. {
  18.  
  19. //Setup the clock
  20. cli(); //Disable global interrupts
  21. TCCR1B |= 1<<CS11 | 1<<CS10; //Divide by 64
  22. OCR1A = 15624; //Count 15624 cycles for 1 second interrupt
  23. TCCR1B |= 1<<WGM12; //Put Timer/Counter1 in CTC mode
  24. TIMSK1 |= 1<<OCIE1A; //enable timer compare interrupt
  25. sei(); //Enable global interrupts
  26.  
  27. //Setup the I/O for the LED
  28.  
  29. DDRD |= 0xff; //(1<<0); //Set PortD Pin0 as an output
  30. PORTD = 0;
  31.  
  32. while(1) { } //Loop forever, interrupts do the rest
  33. }
  34.  
  35. ISR(TIMER1_COMPA_vect) //Interrupt Service Routine
  36. {
  37. PORTD += 1; // (1<<0); //Use xor to toggle the LED
  38. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty