Hello,
the documentation of the ZUno interrupt handlers states that only pinMode(), digitalRead() and digitalWrite() are safe to call from interrupt handlers.
I would like to call the micros() function to measure time between pulses. Will that cause any problems? Any alternatives you could think of?
Thanks
-Roland
Safe functions in interrupt handler
-
- Posts: 255
- Joined: 26 Jul 2015 17:29
Re: Safe functions in interrupt handler
I think Z-Uno does not have a micros() function. I might be wrong about that, but I cannot find it in the Z-Uno libraries and it is not listed on the reference page. Did you mean to write "millis()"?
Out of curiosity, what resolution do you need?
Would counting in the 1ms timer interrupt work for you?
http://z-uno.z-wave.me/Reference/1msTimer/
Out of curiosity, what resolution do you need?
Would counting in the 1ms timer interrupt work for you?
http://z-uno.z-wave.me/Reference/1msTimer/
Meet me here: https://forum.fibaro.com/index.php?/pro ... rgebruers/ or here: memberlist.php?mode=viewprofile&u=564463
Re: Safe functions in interrupt handler
Using deep functions in the interrupt is bad as it can kill the stack.
In your case as suggested by @petergebruers you are suggested to use 1ms or GPT timer and increment a global variables. Use this variable as your tick counter in another interrupt handler
In your case as suggested by @petergebruers you are suggested to use 1ms or GPT timer and increment a global variables. Use this variable as your tick counter in another interrupt handler
Re: Safe functions in interrupt handler
Thanks for the feedback - will use the timer to provide the ticks. I will only get a handful pulses per second so the 1ms timer should provide plenty of accuracy.
And yes petergebruers - there is no micros() on ZUno - thanks for pointing that out. Am still a newby on the ZUno. But it rocks!
-Roland
And yes petergebruers - there is no micros() on ZUno - thanks for pointing that out. Am still a newby on the ZUno. But it rocks!
-Roland
-
- Posts: 255
- Joined: 26 Jul 2015 17:29
Re: Safe functions in interrupt handler
Join the club of happy newbies ... and happy hacking!
Meet me here: https://forum.fibaro.com/index.php?/pro ... rgebruers/ or here: memberlist.php?mode=viewprofile&u=564463