Hi mates, I've some troubles managing this, it looks I need ask an expert about the ATTiny85 registers.. in my opinion they are not really easy to understand and a bit messy up between timers.
As I undersood thery are 2 timers, the timer 0 affect delays and so on, the timer1 is free and can be used.
I need to map Timer1 to the PB4 to make it work as PWM at a frequency about 4KHz 50% (buzzer connected),
looking around for some examples there are some registers involved but I can't figure out their sense:
GTCCR, TCCR1, OCR1B, OCR1C..
the result si that my PB1 output is locked now, I can't manage it more if I touch these registers, strange.
Thank you for your kind help/eplanation
Probably TCCR1 contains prescaler for both timers, if I change it my timings (like millis() )change, they change also if I affect the register OCR1C but on both timers too..
There are many registers and there is no well explained how they work, codes around haven't adeguate descriptions, for example:
PLLCSR |= (1<<PCKE); // Enable asynchronous mode, sets PWM clock source
(1<<CTC1) | // Enable PWM
(1<<PWM1A) | // Set source to pck
(1<<(CS10)) | // Clear the pin when match with ocr1x
GTCCR = (1<<PWM1B) | (1<<COM1B1);
// Configure counter/timer0 for fast PWM on PB0 and PB1
TCCR0A = 3<<COM0A0 | 3<<COM0B0 | 3<<WGM00;
TCCR0B = 0<<WGM02 | 3<<CS00; // Optional; already set
// Configure counter/timer1 for fast PWM on PB4
TCCR1 = 1<<CTC1 | 1<<PWM1A | 3<<COM1A0 | 7<<CS10;
GTCCR = 1<<PWM1B | 3<<COM1B0;
// Interrupts on OC1A match and overflow
TIMSK = TIMSK | 1<<OCIE1A | 1<<TOIE1;
I really hope somebody can tell me how to change the pwm frequency of PB4 only..