Hi,
a clean mathematical solution is to calculate using prime factorization.
10ms x 20MHz = 200,000 counts
this is: 2^6 x 5^5
often prescalers can just divide by 2^n. In this case 2^6 which is 64.
Now you still have 5^5 (= 3125) done with a counter.
an 8 bit counter can't do this, because it´s limited to 256.
--> so you may do it with a 16 bit counter.
other solutions are:
1)
using an 8 bit counter with 5^3 (= 125). This generates an interrupt every 0.4ms.
Now you may use a software counter for the remaining 5^2 (= 25) to get 10ms (0.4ms x 25 = 10ms)
2a)
using a more suitable XTAL frequency.
in this case: the popular 3.6864MHz.
prescaler: 256
8 bit counter: 144
2b) going to the limit:
prescaler: 256
8 bit counter: 256
makes a 6.5536MHz Quarz. Indeed Farnell does show them but not on stock.
2C)
16MHz
prescaler: 256
8 bit counter: 125 (generates 2ms timeout)
software counter: 5
Klaus