Software Timers and SparkIntervalTimer

Hi all,

I need to call a function every X amount of milliseconds which could be larger than 65535. Therefore i can not use Software Timers. Right?
How should i do it? System Interrupts? Every how many ms are those interrupts called?

And another one.
Is it possible to use SoftwareTimers and SparkIntervalTimer at the same time or there will be conflicts between them?



Why would you not be able to do that with Software Timers?
You are dealing with a 32 bit system where integer reaches from -2^31 (-2147483648) to +2^31 - 1 (+2147483647) and unsigned int as used for the SW Timer interval 0 ~ 2^32 - 1 (4294967295) that should be good for just over seven weeks between triggers :wink:

But even if you were up against a 16bit integer, keeping a counter which only increments the counter on each visit and returns, and only once the counter exceedes the desired scaling factor does actually do the intended job, would be the way to go then.

And Software Timers are completely independent of interrupt driven SparkIntervalTimers and the frequency at which the interrupts would fire is set by your code (in µs or half-ms).

1 Like

Thanks @ScruffR for answering.
I thougth that because of this from the docs:

Timer timer(period, callback, one_shot)
period is the period of the timer in milliseconds (unsigned int)

I understood unisgned int meant 16 bit intenger.
So i could go up to 4294927295 miliseconds with the timer?

Thanks again

Nope, as said on a 32bit system unsigned int is equal to uint32_t

1 Like