counting external events

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
v923z
Posts: 41
Joined: Mon Dec 28, 2015 6:19 pm

counting external events

Post by v923z » Thu Jan 18, 2018 7:57 pm

Hi all,

On the pyboard, is it possible to set up any of the pins to count external events? I know that I can do that with interrupts, but what if the count rate is so high that interrupts are no longer a viable option? I would basically like to use the hardware counter, and the chip supports that, but I have the feeling that those functions are not exposed at all in micropython.

Thanks,

Zoltán

User avatar
dhylands
Posts: 2841
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: counting external events

Post by dhylands » Thu Jan 18, 2018 8:09 pm

I put together an example in this thread which shows you how to do that:
viewtopic.php?f=6&t=3370

v923z
Posts: 41
Joined: Mon Dec 28, 2015 6:19 pm

Re: counting external events

Post by v923z » Thu Jan 18, 2018 8:12 pm

Fantastic, many thanks, Dave! Indeed, one has to go to the bit level settings of the hardware. In any case, brilliant example, not only for the frequency counter, but also for the low-level manipulation of the hardware.

Post Reply