Software challenge

could you do something like (not sure how) arrange an interrupt to go off every 1 mS
in a loop increment a counter
when the timer ticks
see what the value counter is
save it in an array clear it
rinse & repeat

average the results in the array
:shrugs: