Thanks Cass,<div> I think I've thought of a possible solution already... (came just after posing the question to the group as usual) My solution, is to increase the timer size from (10bit to 16bit). It only works since I know the pulse isn't longer than 1 period of the timer, otherwise I'm still puzzled how you'd do it.</div>
<div>Will think of another question so someone can try and claim the chocolate fish...</div><div>/s</div><div><br><div class="gmail_quote">On 22 July 2011 16:56, Cass Jones <span dir="ltr"><<a href="mailto:jones.cass@gmail.com">jones.cass@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Does the other interrupt need to be an interrupt?<br>
Could you just have it in the main loop and check for whatever it is<br>
that triggers the<br>
interrupt?<br>
<br>
Conversely if it has to happen as an interrupt then during the<br>
interrupt could you check for a<br>
change in the voltage level of your pulse width signal and then alter<br>
the rise / fall detector<br>
and reset the counter appropriately?<br>
<br>
The first option I suspect would be more reliable.<br>
<br>
-Cass<br>
<br>
On Fri, Jul 22, 2011 at 4:24 PM, Synco Reynders<br>
<div class="im"><<a href="mailto:synco.reynders@gmail.com">synco.reynders@gmail.com</a>> wrote:<br>
</div><div><div></div><div class="h5">> Well, I feel honored for winning the chocolate fish, and sorry for anyone<br>
> who hasn't got a mute function on this email thread.<br>
> I've had a frustrating day trying to code up a brushless DC motor<br>
> controller... (hence the procrastinating).<br>
> Anyway I'd like to put this winning chocolate fish up for grabs again to the<br>
> first person that tells me how to measure a pulse-width (connected to an<br>
> external interrupt), glitch-free!! :<br>
> This is roughly what I got:<br>
> #define TIMERWRAP 1024<br>
> ISR(ExternalInterrupt) // highest priority<br>
> {<br>
> if (triggered on +ve edge) {<br>
> set to trigger on -ve edge;<br>
> count = TIMERWRAP - Timer;<br>
> }<br>
> else {<br>
> set to trigger on +ve edge;<br>
> count += Timer;<br>
> // Now Count should be the pulse length... but it has glitches see<br>
> below<br>
> }<br>
> }<br>
> ISR(TimerOverflow) // overflows at TIMERWRAP ticks<br>
> {<br>
> count += TIMERWRAP;<br>
> ....<br>
> }<br>
> ISR(other)<br>
> {<br>
> ...<br>
> }<br>
> Now the problem occurs (very infrequent) when both the TimerOverflow and<br>
> External interrupt occur while another (non-nesting) ISR is being processed.<br>
> The Ext Interrupt will be processed first therefore missing out on the<br>
> extra TIMERWRAP. I've tried compensating by reading the interrupt flag<br>
> register when processing the external interrupt, it reduces the frequency of<br>
> glitches but as-long as there is any time between reading the flags register<br>
> and the timer I get glitches.<br>
> Is this one of those impossible micro-processor problems?<br>
><br>
><br>
> On 22 July 2011 14:55, Charles Manning <<a href="mailto:manningc2@actrix.gen.nz">manningc2@actrix.gen.nz</a>> wrote:<br>
>><br>
>> On Friday 22 July 2011 14:46:43 Synco Reynders wrote:<br>
>> > HP-12C is a finacial calculator.<br>
>><br>
>> Synco wins the prize!<br>
>><br>
>> Yes folks, the HP-12C has been in continuous production for over 30 years<br>
>> and<br>
>> is still the preferred choice of accountants and auditors the world over.<br>
>><br>
>> There have been some slight internal changes to adjust to changes in<br>
>> manufacturing processes, but the 12C looks the same and does the same<br>
>> thing<br>
>> as it has always done.<br>
>><br>
>> As with most "real" HP calculators, it's RPN which makes it faster to use<br>
>> than<br>
>> those damn "arithmetic" calculators. Anyone who can't use RPN doesn't know<br>
>> what they're missing!<br>
>><br>
>> -- Charles<br>
>><br>
>><br>
>><br>
>> > /s<br>
>> ><br>
>> > On 22 July 2011 14:42, Cass Jones <<a href="mailto:jones.cass@gmail.com">jones.cass@gmail.com</a>> wrote:<br>
>> > > The F91w still looks the same as far as I know, wikipedia reckons they<br>
>> > > have only been around since 1991<br>
>> > ><br>
>> > > On Fri, Jul 22, 2011 at 2:40 PM, Charles Manning<br>
>> > ><br>
>> > > <<a href="mailto:manningc2@actrix.gen.nz">manningc2@actrix.gen.nz</a>> wrote:<br>
>> > > > On Friday 22 July 2011 14:33:35 Synco Reynders wrote:<br>
>> > > >> Digital watch?<br>
>> > > ><br>
>> > > > I don't want a category of item. I want a Make/Model that is the<br>
>> > > > same<br>
>> > > > as<br>
>> > ><br>
>> > > it<br>
>> > ><br>
>> > > > was years ago with no cosmetic changes.<br>
>> > > ><br>
>> > > > While Casio G-Shocks have been around for well over 20 years they<br>
>> > > > are<br>
>> > > > not<br>
>> > ><br>
>> > > the<br>
>> > ><br>
>> > > > same model as the original ones and don't look the same.<br>
>> > > ><br>
>> > > > Hints so far:<br>
>> > > > It takes batteries<br>
>> > > > It has an LCD<br>
>> > > > If you have one you probably wear a tie.<br>
>> > > ><br>
>> > > > No more hints yet to give others a chance...<br>
>> > > ><br>
>> > > >> /s<br>
>> > > >><br>
>> > > >> On 22 July 2011 14:31, Charles Manning <<a href="mailto:manningc2@actrix.gen.nz">manningc2@actrix.gen.nz</a>><br>
>> > > >> wrote:<br>
>> > > >> > On Friday 22 July 2011 14:24:23 Cass Jones wrote:<br>
>> > > >> > > Oh a pocket calculator the fx-82 I presume<br>
>> > > >> ><br>
>> > > >> > Getting closer.<br>
>> > > >> ><br>
>> > > >> > The FX-82 is not a single model. It is a family of models with<br>
>> > ><br>
>> > > different<br>
>> > ><br>
>> > > >> > capabilities and different look and feel.<br>
>> > > >> ><br>
>> > > >> > What I am looking for is a gizzmo that looks identical over the<br>
>> > > >> > last<br>
>> > ><br>
>> > > many<br>
>> > ><br>
>> > > >> > decades (except for different "Made In xxx" etc).<br>
>> > > >> ><br>
>> > > >> > One manufacturer. One model. Looks exactly the same.<br>
>> > > >> ><br>
>> > > >> > Hint3: If you have one you probably wear a tie.<br>
>> > > >> ><br>
>> > > >> > > On Fri, Jul 22, 2011 at 2:23 PM, Charles Manning<br>
>> > > >> > ><br>
>> > > >> > > <<a href="mailto:manningc2@actrix.gen.nz">manningc2@actrix.gen.nz</a>> wrote:<br>
>> > > >> > > > These are not the same gadget. They are different models made<br>
>> > > >> > > > by<br>
>> > > >> > > > different manufacturers.<br>
>> > > >> > > ><br>
>> > > >> > > > The answer I want is a fully functional gizzmo made by the<br>
>> > > >> > > > same<br>
>> > > >> > > > manufacturer under the same model number for decades.<br>
>> > > >> > > ><br>
>> > > >> > > > Hint 2: It has an LCD.<br>
>> > > >> > > ><br>
>> > > >> > > > On Friday 22 July 2011 14:20:11 Synco Reynders wrote:<br>
>> > > >> > > >> Light-bulb? Fuse? Spark-plugs? Torch? Door-bell? ...<br>
>> > > >> > > >> Hoping to get atleast 1 chocolate fish ;-)<br>
>> > > >> > > >> /s<br>
>> > > >> > > >><br>
>> > > >> > > >> On 22 July 2011 14:08, Charles Manning<br>
>> > > >> > > >> <<a href="mailto:manningc2@actrix.gen.nz">manningc2@actrix.gen.nz</a>><br>
>> > > >> ><br>
>> > > >> > wrote:<br>
>> > > >> > > >> > I hereby off a choc fish to the first correct answer to<br>
>> > > >> > > >> > this<br>
>> > > >> > > >> > question...<br>
>> > > >> > > >> ><br>
>> > > >> > > >> > In this crazy world we live in, electronic gadgets change<br>
>> > > >> > > >> > all<br>
>> > ><br>
>> > > the<br>
>> > ><br>
>> > > >> > > >> > time. Try to<br>
>> > > >> > > >> > find something you bought last and you will find it has<br>
>> > > >> > > >> > been<br>
>> > > >> ><br>
>> > > >> > replaced<br>
>> > > >> ><br>
>> > > >> > > >> > by a different model.<br>
>> > > >> > > >> ><br>
>> > > >> > > >> > There is, however, one electronic gadget that has been in<br>
>> > > >> > > >> > production for a few<br>
>> > > >> > > >> > decades. Same model. Same function. Still in production.<br>
>> > > >> > > >> ><br>
>> > > >> > > >> > What is it?<br>
>> > > >> > > >> ><br>
>> > > >> > > >> > Charles<br>
>> > > >> > > >> ><br>
>> > > >> > > >> > _______________________________________________<br>
>> > > >> > > >> > Chchrobotics mailing list<br>
>> > > >> > > >> > <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
>> > > >> > > >> > <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>> > > >> > > >> > Mail Archives:<br>
>> > ><br>
>> > > <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>> > ><br>
>> > > >> > > >> > Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
>> > > >> > > >> > Meeting Time and Location uncertain while Science Alive is<br>
>> > > >> > > >> > out<br>
>> > ><br>
>> > > of<br>
>> > ><br>
>> > > >> > > >> > action.<br>
>> > > >> > > >> ><br>
>> > > >> > > >> > When replying, please edit your Subject line to reflect<br>
>> > > >> > > >> > new<br>
>> > > >> > > >> > content.<br>
>> > > >> > > ><br>
>> > > >> > > > _______________________________________________<br>
>> > > >> > > > Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
>> > > >> > > > <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>> > > >> > > > Mail Archives:<br>
>> > > >> > > > <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>> > > >> > > > Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
>> > > >> > > > Meeting Time and Location uncertain while Science Alive is<br>
>> > > >> > > > out<br>
>> > > >> > > > of<br>
>> > > >> ><br>
>> > > >> > action.<br>
>> > > >> ><br>
>> > > >> > > > When replying, please edit your Subject line to reflect new<br>
>> > ><br>
>> > > content.<br>
>> > ><br>
>> > > >> > > _______________________________________________<br>
>> > > >> > > Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
>> > > >> > > <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>> > > >> > > Mail Archives:<br>
>> > > >> > > <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>> > > >> > > Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
>> > > >> > > Meeting Time and Location uncertain while Science Alive is out<br>
>> > > >> > > of<br>
>> > > >> > > action.<br>
>> > > >> > ><br>
>> > > >> > > When replying, please edit your Subject line to reflect new<br>
>> > > >> > > content.<br>
>> > > >> ><br>
>> > > >> > _______________________________________________<br>
>> > > >> > Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
>> > > >> > <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>> > > >> > Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>> > > >> > Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
>> > > >> > Meeting Time and Location uncertain while Science Alive is out of<br>
>> > ><br>
>> > > action.<br>
>> > ><br>
>> > > >> > When replying, please edit your Subject line to reflect new<br>
>> > > >> > content.<br>
>> > > ><br>
>> > > > _______________________________________________<br>
>> > > > Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
>> > > > <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>> > > > Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>> > > > Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
>> > > > Meeting Time and Location uncertain while Science Alive is out of<br>
>> > > > action.<br>
>> > > ><br>
>> > > > When replying, please edit your Subject line to reflect new content.<br>
>> > ><br>
>> > > _______________________________________________<br>
>> > > Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
>> > > <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>> > > Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>> > > Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
>> > > Meeting Time and Location uncertain while Science Alive is out of<br>
>> > > action.<br>
>> > ><br>
>> > > When replying, please edit your Subject line to reflect new content.<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
>> <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
>> Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
>> Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
>> Meeting Time and Location uncertain while Science Alive is out of action.<br>
>><br>
>> When replying, please edit your Subject line to reflect new content.<br>
><br>
><br>
> _______________________________________________<br>
> Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
> <a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
> Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
> Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
> Meeting Time and Location uncertain while Science Alive is out of action.<br>
><br>
> When replying, please edit your Subject line to reflect new content.<br>
><br>
<br>
_______________________________________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
<a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
Web site: <a href="http://kiwibots.org" target="_blank">http://kiwibots.org</a><br>
Meeting Time and Location uncertain while Science Alive is out of action.<br>
<br>
When replying, please edit your Subject line to reflect new content.<br>
</div></div></blockquote></div><br></div>