Skip to main content
8 events
when toggle format what by license comment
Jun 16, 2015 at 13:01 comment added user3753934 Ah, gotcha. That's helpful, I forgot Serial + ISR is bad. Anyway looks like the code above works perfectly, so I'm gonna make sure I understand how it works and just use that. Thank you for getting me on the right track!
Jun 16, 2015 at 11:23 comment added Nick Johnson You shouldn't try and print to serial from an ISR - it'll cause lots of strange things to happen. I don't know what you mean in your last comment, can you clarify?
Jun 15, 2015 at 20:35 comment added user3753934 I tried doing it with global variables, but the resolution isn't high enough... the difference between the interval for 75kHz and 50kHz is only a couple clock ticks.
Jun 15, 2015 at 19:16 comment added user3753934 Actually this is really strange, it seems to be affected by the Serial output.
Jun 15, 2015 at 18:40 comment added user3753934 I've updated my answer with the second iteration of code, if you get the chance to take a look. Thanks so much!
Jun 15, 2015 at 18:32 comment added user3753934 Hm. It seems to be getting stuck in the "while(flag != WAIT);" loop. I inserted a Serial.println(flag) at various points, and it outputted a 0 (first interrupt, Capt1 = ICR1), a 1 (second interrupt, Capt2 = ICR1), and then infinite 2s (flag = WAIT). The interrupt is clearly still working because it continues to print 2s... I just don't understand why it's not exiting the while(flag != WAIT) loop.
Jun 15, 2015 at 15:27 history edited Nick Johnson CC BY-SA 3.0
added 623 characters in body
Jun 15, 2015 at 14:58 history answered Nick Johnson CC BY-SA 3.0