Hi I wonder if anyone could give me an example how the
TickGetDiv256();
function works. It came from Microchip in Tick.c
Im trying to count for 2 houre's, if fullfilled an engine will be stopped.
I could might use "threshold = tick + TICKS_PER_SECOND * 60;
" function.
But I dont know if it would be good to use it for this amount of time: threshold = tick + (TICKS_PER_SECOND * 60 * 60)*2
;
Kind Regards
Judging from the MPLAB C guide, the largest integer data type supported by the C compiler is 32-bits. From what I can glean elsewhere, the tick counter is six bytes - TickGetDiv256
returns the 'middle four' of these bytes.
Since the full six bytes of the tick counter cannot fit into a 32-bit integer, you'd use TickGetDiv256
to extract the middle bytes and thus have a count of the number of '256 tick' intervals that have passed since the counter was started. Of course, this isn't strictly true since it's ignoring the highest byte of the tick counter. You'd use this function if the lower four bytes of the tick counter do not provide enough of a range for the timespan you're interested in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With