I have a problem:
I work with servo’s and values I need to read.
So I need to use Timer2 for this that those two don’t interfere with one another. I’m trying to understand TCCR2B better, but all the things i under stand so far is that its a setting for the prescale.
i could read that from the datasheet ( https://ww1.microchip.com/downloads/en/devicedoc/atmel-2549-8-bit-avr-microcontroller-atmega640-1280-1281-2560-2561_datasheet.pdf )
(for 5 is it 128)
i also know that it is mend to change the working speed, form 16Mhz to a lower one,
depending on the prescale.
cli(); TCCR2A = 0; TCCR2B = 5; // interrupt in register B TCNT2 = 0; OCR2A = 250; TCCR2A |= (1<<WGM21); TCCR2B |= (1<<CS21); TIMSK2 |= (1<<OCIE2A); // enable timer compare interrupt in dit gaval timer 2 sei();
like you can see in my code i use for TCCR2B 5, but if i read document’s about it, i see others use 0x05 and things like that,
also this img when TCCR2B = 5 dus it make me be in mode 5.
( and i also vind something about how to calculate my hz , is this one right ? (16 MHz / (5 * (250 + 1)) =12 749hz) )
this is really complex, i really hope you can help me?