timing functions issue (delay()) on tiny44
dragan1alex opened this issue · comments
Is delay based on both the timers on the tiny44? Because whenever I change the clock source on timer0 or timer1 the delay is acting strangely.
The code I used for timer1 initialization:
void initTimer1() {
cli();
TCCR1B = (1<<WGM12) | (1 << CS10);
OCR1A = 64;
TIMSK1 |= (1 << OCIE1A);
sei();
}
ISR(TIM1_COMPA_vect) {
if (currentStep < 255)
currentStep += 1;
else
currentStep = 0;
for (uint8_t x = 0; x <= 10; x++)
currentStep < pwmled[x] ? (x < 8 ? PORTA |= (1 << p[x]) : PORTB |= (1 << p[x])) : (x < 8 ? PORTA &= ~(1 << p[x]) : PORTB &= ~(1 << p[x]));
}
It's basically a software PWM (poor?) implementation. It changes the delay significantly, the same applies if I use timer0 instead.
Don't mind this issue, nothing wrong with the library, I'm just...let's say I still have lots to learn :)