When I program, I like to get one small piece of the puzzle working and then start digging into the meaty bits. This is just a simple program that blinks and LED on PORTD. It's based on a 1ms Timer 0 interrupt. Good times. /*Bill BaiBlinking LED based on tutorial from Sparkfunhttp://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=93*/#include <avr/io.h>#include <avr/interrupt.h>//Define functions//======================void ioinit(void); //Initializes IOvoid init_Timer0(void);//======================int main (void){ ioinit(); //Setup IO pins and defaultsinit_Timer0();sei(); //enable interrupts while(1){} return(0);}unsigned int count = 1;ISR(TIMER0_OVF_vect){if(count == 500){count = 1;PORTD ^= 0xFF;}count++;TCNT0 = 0xB2; //reset timer 0 counter}void ioinit (void){ //1 = output, 0 = input DDRB = 0xFF; //All outputs DDRC = 0xFF; //All outputs DDRD = 0xFF; //PORTD (RX on PD0)}//Initialize Timer0void init_Timer0(void){TCNT0 = 0xB2;TCCR0A = 0;TCCR0B = 4;TIMSK0 = 1;} |