void init_port();
void init_timer();
void setup() {
volatile long i;
int j=0;
init_port();
init_timer();
Serial.begin(9600);
while(1)
{
for(i=0; i<1000000; i++);
Serial.println(j,DEC);
j++;
}
}
void init_timer(){
volatile char *Timer1_TCCR1A = 0x80;
volatile char *Timer1_TCCR1B = 0x81;
volatile short *Timer1_TCNT1 = 0x84;
volatile short *Timer1_OCR1A = 0x88;
volatile char *Timer1_TIMSK1 = 0x6F;
*Timer1_TCCR1A = 0;
*Timer1_TCCR1B = 0;
*Timer1_TCNT1 = 0;
*Timer1_OCR1A = 60000; // compare match register 16MHz/256/2Hz 31250
*Timer1_TCCR1B = 0x0C; // CTC mode & 256 prescaler
*Timer1_TIMSK1 = 0x02; // enable timer compare interrupt
}
void init_port()
{
volatile char *portf_dir = (volatile char *)0x30;
*portf_dir = 0x01;
}
ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
volatile char *portf_data = (volatile char *)0x31;
*portf_data ^= 0x01;
}
void loop() {
// put your main code here, to run repeatedly:
}