timer.h: namespace timer { class timer_8 { public: static void init(uint8_t tccr0) { cbi(TIMSK, TOIE0); TCCR0 = tccr0; } static void call(uint8_t cycles, void (*function)()) { m_func = function; TCNT0 = (255 - (cycles-1)); sbi(TIMSK, TOIE0); } static void _exec() { cbi(TIMSK, TOIE0); (*m_func)(); } private: static void (*m_func)(); }; } timer.cpp: #include "D:/projects/AVR/libs/timer.h" void timer::timer_8::init(uint8_t tccr0) { cbi(TIMSK, TOIE0); TCCR0 = tccr0; } void timer::timer_8::call(uint8_t cycles, void (*function)()) { m_func = function; TCNT0 = (255 - (cycles-1)); sbi(TIMSK, TOIE0); } void timer::timer_8::_exec() { cbi(TIMSK, TOIE0); (*m_func)(); } void (*timer_8::m_func)() = NULL;