Würdest Du bitte angeben, von welchem µC Du redest? Dass es ein AVR
ist, ist anzunehmen. Beim 88/168/328P findet sich im Datenblatt unter
TCNT0:
1 | Writing to the TCNT0 Register blocks (removes) the Compare
|
2 | Match on the following timer clock. Modifying the counter (TCNT0) while the counter is running,
|
3 | introduces a risk of missing a Compare Match between TCNT0 and the OCR0x Registers.
|
Es klappt bei diesem Typ also nicht - jedenfalls nicht bei Timer 0. Für
die anderen darfst Du selbst nachsehen. Ist ja nicht groß, der Absatz
zu TCNT in der Registerbeschreibung.
EDIT: Es findet sich sogar genau die Antwort auf Deine Frage im
besagten Datenblatt, nämlich
1 | 12.5.3 Using the Output Compare Unit
|
2 | [...] If the value written to TCNT0
|
3 | equals the OCR0x value, the compare match will be missed, resulting in incorrect waveform
|
4 | generation.
|
und aus dem Kontext geht hervor, dass das für alle Modes gilt.