This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:examples:timer:periodic_interrupt [2015/11/13 08:54] – heikopikner | en:examples:timer:periodic_interrupt [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Periodic interrupt ====== | ====== Periodic interrupt ====== | ||
- | //Necessary knowledge: | + | //Necessary knowledge: |
+ | [HW] [[en: | ||
+ | [AVR] [[en: | ||
+ | [LIB] [[en: | ||
+ | [LIB] [[en: | ||
===== Theory ===== | ===== Theory ===== | ||
Line 77: | Line 81: | ||
ISR(TIMER1_CAPT_vect) | ISR(TIMER1_CAPT_vect) | ||
{ | { | ||
- | // Changing the state of the green LED. | + | // Changing the state of the green LED |
pin_toggle(led_green); | pin_toggle(led_green); | ||
} | } | ||
Line 87: | Line 91: | ||
pin_setup_output(led_green); | pin_setup_output(led_green); | ||
- | // Seting the timer up in the CTC mode. | + | // Seting the timer up in the CTC mode |
timer1_init_ctc( | timer1_init_ctc( | ||
TIMER1_PRESCALE_1024, | TIMER1_PRESCALE_1024, | ||
Line 97: | Line 101: | ||
timer1_set_input_capture_value(14400); | timer1_set_input_capture_value(14400); | ||
- | // Allowing interruption of achieving the value. | + | // Allowing interruption of achieving the value |
timer1_input_capture_interrupt_enable(true); | timer1_input_capture_interrupt_enable(true); | ||
- | // Allowing global interruption. | + | // Allowing global interruption |
sei(); | sei(); | ||
- | // Endless loop. | + | // Endless loop |
while (1){ } | while (1){ } | ||
} | } |