<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div style="" class=""><span style="" class="">I agree with the others, it sounds like the trigger should get the interrupt.</span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br style="" class=""><span style="" class=""></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span style="" class="">Like Jeff said, you want your interrupt to execute in as short of a time as possible. One approach might be to just set a flag on trigger presses then process the action in the main
 loop. That could still leave you with 1 sec latency if you are detecting IR hits, which would probably be pretty noticeable.</span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br style="" class=""><span style="" class=""></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span style="" class="">I have never tried this on a tiny, but I'm making it a personal mission to find a use case for it, but you could use an RTOS, like <a style="" class="" href="http://www.femtoos.org/">http://www.femtoos.org/</a>  Looks promising. I've used ChibiOS on Cortex M3/4's and found it pretty nice to work with, YMMV. <br></span></div><div class=""
 style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span style="" class=""><br></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span style="" class="">The other alternative approaches might be to try to reduce the 1 second detection loop. Or, to try to architect your own "cooperative multitasking" or coroutines. In short, write your detect loop so that instead of looping for 1 second, it just does a little bit of work and returns to the main loop, remembering where is was in the loop between each call. I use this approach a lot.</span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica
 Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span style="" class=""></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span style="" class="">I will say that you should try to handle debouncing the trigger in hardware as much as you can. I've tried software debouncing mechanical encoders in interrupt driven routines, and I can attest that it is maddening.</span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span style="" class=""></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida
 Grande,sans-serif; background-color: transparent; font-style: normal;"><span style="" class="">Lastly, you *could* always just buy a separate tiny for the detection, but I have no ulterior motive or bias there ;)</span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span style="" class=""></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br><span style="" class=""></span></div><div class="" style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span style="" class=""><br style=""
 class=""></span></div><div style="" class=""><br style="" class=""></div>  <div class="" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 10pt;"> <div class="" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="" class="" dir="ltr"> <hr style="" class="" size="1">  <font style="" class="" face="Arial" size="2"> <b style="" class=""><span class="" style="font-weight:bold;">From:</span></b> Joe Fair <joe@fairanswers.com><br style="" class=""> <b style="" class=""><span class="" style="font-weight: bold;">To:</span></b> triembed@triembed.org <br style="" class=""> <b style="" class=""><span class="" style="font-weight: bold;">Sent:</span></b> Saturday, July 26, 2014 4:09 PM<br style="" class=""> <b style="" class=""><span class="" style="font-weight: bold;">Subject:</span></b> [TriEmbed] IR sensor vs trigger<br
 style="" class=""> </font> </div> <div style="" class=""><br style="" class=""><div style="" class="" id="yiv7965787466"><div style="" class="">Ok.  I'm pretty close on getting my home made laser tag with at tiny 85s going, but now i have a question about design.</div>
<div style="" class="">The loop I'm using detects a trigger pull, then a hit on the sensors.  however, The pulse in function I'm using to sense IR ha a timeout of 1 second.  If there is no inbound signal it is only checking got a trigger pull once a second.</div>

<div style="" class="">So i need to use an interrupt, but does it matter if i use one on the trigger pull or the ir sensor? </div>
<div style="" class="">Joe<br style="" class="">
</div></div><br style="" class="">_______________________________________________<br style="" class="">Triangle, NC Embedded Computing mailing list<br style="" class=""><a style="" class="" ymailto="mailto:TriEmbed@triembed.org" href="mailto:TriEmbed@triembed.org">TriEmbed@triembed.org</a><br style="" class=""><a style="" class="" href="http://mail.triembed.org/mailman/listinfo/triembed_triembed.org" target="_blank">http://mail.triembed.org/mailman/listinfo/triembed_triembed.org</a><br style="" class="">TriEmbed web site: <a style="" class="" href="http://triembed.org/" target="_blank">http://TriEmbed.org</a><br style="" class=""><br style="" class=""><br style="" class=""></div> </div> </div>  </div></body></html>