Timeline for How to implement a pulse counter for two clocks on Nano Every?
Current License: CC BY-SA 4.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 28 at 11:15 | comment | added | Edgar Bonet |
@Mo_: Re "Do you think a busy loop would perform better": a busy loop calling digitalRead() may not be any better, as that function is pretty slow. With digitalReadFast() , the busy loop will most likely work fine... until you call Serial.print() , and that method starts doing a (slow) binary-to-decimal conversion.
|
|
May 28 at 11:03 | comment | added | Mo_ | Had a look at timers and ISRs. I'll simply go for a faster processor or buy pre-made HW. Would be fun to implement on Arduino but ATM don't have the time unfortunately. | |
May 28 at 7:04 | comment | added | the busybee |
@Mo_ If you can limit the range of the counters, using a smaller data type like unsigned char could reduce the number of cycles spent in the ISRs.
|
|
May 28 at 7:02 | comment | added | the busybee | @Mo_ For verifying the theory, you could toggle a pin during the ISRs. Make sure to use the library digitalWriteFast that compiles functions with constant pin numbers into a single machine instruction. Then use your oscilloscope. | |
May 27 at 18:57 | comment | added | Questor | @Mo_ It would not, possible fixes, do the edge counting in hardware. Or get a faster processor. | |
May 27 at 15:07 | comment | added | Mo_ | If it's necessary, I could study it. However, it's just a helper, I want it to be easy to understand for people unfamiliar with arduino. So I'll look for a simpler solution first. Thanks for outlining the overhead. Do you think a busy loop would perform better? | |
May 27 at 9:50 | history | answered | Edgar Bonet | CC BY-SA 4.0 |