"here my code" consider using dual slope here. if the counter is above / below the compare value you are setting, in single slope operations (up / down counters), you miss a pulse.
↧