The problem isn't producing the frame rate of a timer interrupt.
the problem is down to producing a 1ms to 2ms on time within the 20ms frame rate.
Its all down to the resolution of the on time.
If you just want a resolution of 1ms then osc frequency can be much lower then if if you want say a resolution 0.1ms
Also the osc frequency and timer settings determines the accuracy of the frame rate.
So we will need to keep increasing timer settings until desired frequency be found (assuming you do not wish to use C code)
If osc frequency is kept low then you may need to increase timer settings so much to get good frame rate accuracy, then there will not be much time left for the routines outside of interrupts.
I will post something in a while for you to look at.
Drakkor wrote:I am still missing what controls the frame rate and the relationship of frequency to time period ( 20ms).
Suppose osc freq is 32MHz you choose a timer interrupt (numbers after decimal point rounded as sloe to 0 as possible) of 1:256
Interrupt period = 122.070Hz = 1/122.070=8.2ms
since 8.2ms is greater than 1ms, that means you can't have the o/p on for 1ms then back off again.
That's the relation ship betwwen the two.
Although it can be done by palcing a small 1ms delay in the timmer interrupt and work, placing time delays within interrupts are not recommended.
Since 1ms = 1/0.001 = 1000Hz then 1000Hz is the minimum timer interrupt frequency.
Then the resolution is 1ms, so you can have on period on for multiples of 1ms
So if you want a resolution of .1ms then timer interrupt frequency must be 1/0.0001= 10KHz
That is why you need the faster oscillator speed.
Going back the the lower resolution 1ms for an example.
The o/p on period can start when count = 0
since count increases by 1 every 1ms then when count =1 output has to go off
then 20ms = count of 20.
So you will need if count = 20 then count = 0
Example if hold = 1ms and drop = 2ms:
Just place at the start of the timer interrupt:
Count = Count +1
Then within the timer interrupt place a decision branch:
If Count = 20 : Count =0: Output = high
(If count =1) && (Drop = 0) then o/p = low
(If count =2) && (Drop = 1) then o/p = low
in reality without C code you will not get and interrupt that triggers exactly every 1ms, so the above was just an example.
Hope this helps
Martin