On Paper: Using Interrupts with the Timer/Counter

The interrupt can be used to create an event when the timer/counter TCNT1 or TCNT0 achieves a specific value. The OCR1A is used to hold this value. The TCCR1B is set to a prescaler of 64 using the Clock Select bits (CS10, CS11 and CS 12) and another control bit called WGM12 (Waveform Generation Mode) CTC Mode (Clear Timer on Compare). This will cause the TCNT1 to go back to 0 when the OCR1A value is hit. sei() is used to enable global interrupts along with the timer interrupts enable control TIMSK.



Back to blog

Leave a comment

Please note, comments need to be approved before they are published.