Skip to main content
Arduino

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Draft saved
Draft discarded
Cancel
7
  • Could you please add to the question a Minimal, Complete, and Verifiable example showing your problem? As it stands, your question is unanswerable without a crystal ball. Commented Jun 21, 2017 at 20:43
  • Interrupts are for short pieces of code that do not block or cause interrupts. You can't call Serial functions and you shouldn't be performing computations. What you should do it toggle a volatile global bool and then exit the interrupt. Next time loop() is executed check to see if the bool has been set and if so doStuff() Commented Jun 22, 2017 at 7:21
  • I've updated my question and gave whole code of my program. Please look at it and advise what can be wrong Commented Jun 22, 2017 at 20:18
  • I have added a 'Update' section to my answer. Commented Jun 22, 2017 at 22:20
  • You wrote: "analogRead(inp)". This alone is a no-no in an ISR: it takes about 110 µs, enough to loose incoming serial data. And also: "exp(-Td/Tdf)". Since Tdf=Td/10, this is exp(−10) ≈ 4.5399930e-5. You should declare it as a constant, rather than repeating the (very expensive) calculation each time. Seriously: forget about interrupts and manage your timings with micros() instead. Commented Jun 23, 2017 at 7:53

AltStyle によって変換されたページ (->オリジナル) /