I wanted to get interrupt with nano seconds [ taking in mind the frequency for one clock pulse is 62.5 nano second ] , however , the only readings in the oscilloscope is in micro.
I did the following :
- pre-scaler is set to one clock increment
- ctc is activated (clear timer on compare match)
I used the code below
const uint16_t t1_comp=50; // compare match value
void setup() {
DDRB |=(1<<PB5);
TCCR1A=0;
//TCCR1B |=0B00001001;
TCCR1B |=(1<<CS10);
TCCR1B &=~(1<<CS11);
TCCR1B &=~(1<<CS12);
TCCR1B |=(1<<WGM12);
TCNT1=0;
OCR1A=t1_comp;
cli();
TIMSK1 |=(1<<OCIE1A);
sei();
}
void loop() {
}
ISR(TIMER1_COMPA_vect)
{
PORTB ^=(1<<PB5);
}
any correction is highly appreciated
BR