/*using Timer 1 for delay in Normal mode(TIMER1 - 16bit)
ATMega2560 clock = 16MHz*/
void T1Delay(void);
void setup() {
volatile uint8_t *DDR_F=(volatile uint8_t *)0x30;
*DDR_F|=(1<<3); //Settng portF 3rd pin as output pin
T1Delay();
}
void T1Delay(){
volatile char *TIMER1_TCCR1A =0x80;
volatile char *TIMER1_TCCR1B =0x81;
volatile uint16_t *TIMER1_TCNT1 =0x84;
volatile uint16_t *TIMER1_OCR1A =0x88;
volatile char *TIMER1_TIMSK1=0x6f;
*TIMER1_TCCR1A =0;
*TIMER1_TCCR1B=0;
*TIMER1_TCNT1 =0; //CTC mode
*TIMER1_TCCR1B=0x0c;// CTC mode & 256 prescalar
*TIMER1_OCR1A = 31250;
*TIMER1_TIMSK1=0x02;// enable interrupt mode for Output compare match A
}
ISR(TIMER1_COMPA_vect)
{
volatile uint8_t *PORT_F=(volatile uint8_t *)0x31;
*PORT_F^=(1<<3);
}
void loop() {
// put your main code here, to run repeatedly:
}