Describe how to generate a makefile (Windows only, sorry)



Set up a main function



Set up your initialization function



Create a timer comparison interrupt



Send a digital value to an output pin

#include<avr/io.h> #include<avr/interrupt.h> int main(void) { return 0; }

Set up the timer



Enable the timer interrupt to go off every ___ ms



Zero the timer



Enable the timer interrupt



Enable a pin on a port for output



Enable global interrupts

#define WGMCRC 0x2; #define CLK1024 0x5; void init(void) { // Step 1 TCCR0A = WGMCRC; TCCR0B = CLK1024; // Step 2 OCR0A = 8; // Step 3 TCNT0 = 0; // Step 4 TIMSK0 |= _BV(OCIE0A); // Step 5 DDRD |= 0x80 // 0x80 referring to bit 7 (remember? 0x80 is 0b10000000) // Step 6 sei(); }

int main(void) { init(); for(;;) ; return 0; }

ISR(TIMER0_COMPA_vect) { }

|X||Y|Z|

|1|1||0|

ISR(TIMER0_COMPA_vect) { PORTD ^= 0x80; }

/* Alexander Hart * July, 2010 * This code is released to the public. * It may be used in any commercial or public application * In classrooms, wherever. However, credit to the original * author is to be preserved. */ #include<avr/io.h> #include<avr/interrupt.h> #define WGMCRC 0x02 #define CLK1024 0x05 ISR(TIMER0_COMPA_vect) { PORTD ^= 0x80; } void init(void) { TCCR0A = WGMCRC; TCCR0B = CLK1024; OCR0A = 8; TCNT0 = 0; DDRD |= 0x80; sei(); } int main(void) { init(); for(;;) ; return 0; }