Dividing hardware timer in software
I have a hardware timer using its updateEvent interrupt to increment a ms_passed variable every 1 ms. I have a freeRTOS task reading ms_passed ( via TaskNotification ) in a while(1) loop to toggle a pin at a given time interval/tempo based on a variable BPM ( beats per minute ).
I would like to be able to divide 4 'clocks' in software based on the ms_passed ticks. I have implemented a rough solution based on a similar way of setting baud rates registers, ( integer and remainder registers ) and use no floating points, but I still get drift. If I run toggle 2 leds, they are in sync initially but end up out of sync with drift introduced after several minutes.
Does anyone know of an example i can look at in case this has already been done or have suggestions on the best approach?
Thanks!
