#include"timerAddress.h"
#include<stdint.h>
//REQ: Blink LED with a delay generated by timer
//PRE-REQ : PICK LED-port: PB,PB7, TIMER-port: B
//SET-PRESCALE: TCCR0B - 0x45 [CS02,CS01,CS00] - 0x5- scales by 1024
// CLK-16MHZ PRESCALE-CLK-15625 ticks/sec
//TCNT0 - 0x46 gives count
//OCR0B - 0x48 Set value to compare - 15625
//TIFR0 - 0x35 [OCF0B-(1<<2)] - Flag will be set if TCNT0==OCR0B
//Write activity to be done in ISR
//TIMSK0 - 0x6E [OCIE0B-(1<<2)]
int main(){
volatile uint8_t* A_DPB = (volatile uint8_t*)DRPB;
*A_DPB |= (1<<7);
volatile uint8_t* A_PB = (volatile uint8_t*)PB;
*A_PB |= (1<<7);
//TIMER-SETTINGS-START-FROM-HERE
//PRE-SACLE TO 1024
volatile uint8_t* A_TCCR0B = (volatile uint8_t*)U_TCCR0B;
*A_TCCR0B = 0x5;
//UPDATE-CLOCK-TICS-TO-COMPARATOR
volatile uint8_t* A_OCR0B = (volatile uint8_t*)U_OCR0B;
*A_OCR0B = 250;
//FLAG-TO-CHECK
volatile uint8_t* A_TIFR0 = (volatile uint8_t*)U_TIFR0;
volatile uint8_t* A_TCNT0 = (volatile uint8_t*)U_TCNT0;
uint8_t count = 0;
while(1){
if(*A_TIFR0 & (1<<2)){
*A_TIFR0 |= (1<<2);
count += 1;
}
if(count >= 62){
*A_PB ^= (1<<7);
count = 0;
}
}
}