PWM frequency change (ATtiny85)

fungus:
it means timer0 counts at the speed of the CPU clock (it's not divided by anything). You can divide by 1, 8, 64, 256, etc., using CS02, CS01 and CS00.

Ok, with last three bits in line 0b11111001 i set divider using CS02, CS01 and CS00. I found table fot that in datasheet and i can understand that.

If your chip is running at 8MHz then 0x01 in TCCR0B means your PWM frequency is 8000000/256 = 31.24kHz

8000000/256 = 31.24kHz but why "0x01" (binary 0000 0001) means 256? Is there also a table for that 0x01 means mode "divide with 256"?

If i make a conclusion..

With line "TCCR0B = TCCR0B & 0b11111001 | 0x01;" in void setup() i set frequency on port PB0 and PB1 to 31,24 kHz since my CPU speed is 8 MHz. Period of PWM is set with line "analogWrite(port, value)".. (value 255 is max or equal to HIGH, always on).


I test it with this line "TCCR0B = TCCR0B & 0b11111001 | 0x01;" but it doesn't work.. Fan have the same speed, no matter what PWM period i choose.

With line analogWrite(fan, 128); or analogWrite(fan, 255); speed of fan is the same.. If i remove upper "TCCR0B ..." line it works (just with annoyng noise at half speed) so hardware wiring should be ok.