Hi Bart,
you will not be able to create a 100KHz frequency with a timer via an interrupt. This is due to the required register saving before and reloading after the interrupt. That requires around 110 cycles.
A free running square output is easily done via hardware with the CTC mode. You configure it like this:
Config Timer0 = Timer , Prescale = 1 , Clear_timer = 1 , Compare_a = Toggle
Compare0a = 39
The timer will count from 0 to 39 (40 steps). At that point it will toggle the output and start from 0 again.
With 8MHz frequency you will get 100KHz output signal at OC0A (PD.6).
↧