Hello, I've written a code for ATtiny24A which includes "delay()" function. I noticed my buzzer which is connected to ATtiny was beeping longer than expected. I've set the buzzer pin high and delayed the turn off by: delay(1000);
The buzzer beeped 16 seconds precisely. I realized the compiler assumes default 16Mhz clock of Arduino. But my settings are correct:
Settings:
Also I use Arduino as ISP, I've uploaded the ArduinoISP sketch to Arduino beforehand by enabling the "old style wiring" definition.
I've seen things about fuses but couldn't manage to fix it, I'll be glad if you help. Thanks.
Also, millis() doesn't work because I configured Timer 0 differently. I fixed the delay issue by dividing the delay values by 16 but still would love to know a better solution. The code you gave checks if millis() works properly. I created another sketch without Timer configuration and yes, it created a 1 second delay. Even the regular "delay()" function works.
I then have done the same configurations in timer0 and timer1, timer1 doesn't ruin anything but I shouldn't touch timer0 otherwise millis and delay are ruined. problem solved. I already knew delay was counted in timer0 but it didn't make sense that timer was off by 1/16 exactly. Anyway problem solved, I will rewrite my code without touching timer0.