![]() |
Forum Index : Microcontroller and PC projects : high-resolution timer/counter?
Author | Message | ||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2442 |
this is one for Geoff i suspect! i've just been reading about TassyJim's rather clever idea in this thread for implementing a high-resolution timer on the micromite: https://www.thebackshed.com/forum/ViewTopic.php?TID=10317 PWM 1, 100000, 50 SETPIN 15, CIN ' link pins 4 and 15 on 28-pin MX170 [...] tick = PIN(15) yielding a 10ms counter that shouldn't overflow for around 2 million years. it left me wondering if there was any high-resolution (better than 1ms) timer/counter already configured on the MX170 that can be read using a simple PEEK? i'm thinking this would be rather useful for generating timestamps used for decode streams of oddly-formatted data received over the air. even if there is not already any usable timer/counter, it would be rather handy if one could do: PWM channel, frequency to set up a pwm channel without any associated pins, and then read the counter value using something like: tick = PWM (channel) or even tick = TIMER (channel) this sort of addition would remove the need to sacrifice 2 I/O pins to the task. and i don't think it would require using any more tokens ![]() cheers, rob :-) Edited 2020-06-29 02:01 by robert.rozee |
||||
CaptainBoing![]() Guru ![]() Joined: 07/09/2016 Location: United KingdomPosts: 2170 |
As far as fast count inputs go, would 20MHz do ya? https://www.thebackshed.com/forum/ViewTopic.php?TID=10813 Edited 2020-06-29 07:17 by CaptainBoing |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5091 |
There is so much hidden treasure here. Would it be an idea to collect this distributed knowledge into a database ? Maybe use the fruit_of_the_shed website for a library of Cfunctions Something like: Cfunction Target Designed Verified Purpose Link Link_thread Comment FASTCOUNT MM+ v5.03.02 v5.05.01 count fast xxxx yyyyy.html only for MX170 etc... Regards, Volhout PicomiteVGA PETSCII ROBOTS |
||||
paceman Guru ![]() Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
@Volhout The fruit-of-the-shed site is most likely the best place to achieve something like that and the time and effort CaptainBoing (and others) have already put into it has made it a great resource for Maxi/MicroMite/MMBasic info. Check it out if you haven't already, there's lots of good stuff from TBS members, plus TBS links in the posts. Fruit-of-the-shed is a Wiki which means account holders input and maintain their own contributions. As CaptainBoing says in his introduction page, a Wiki is more sustainable than any one person trying to maintain an ever-growing library; your call has not been the first for this. Further to that, there are a number of links to TBS topics and posts in the "Documentation/Embedded C Modules/*.txt" files that Geoff includes with the MMBasic downloads. Those C Modules are gems too. Greg |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2442 |
unfortunately this doesn't appear to do what i'm after. i'd like to have a counter within the MX170 that counts up at somewhere around 100kHz (anything above about 20kHz would do), and that i can be read so as to use it for a 'timestamp'. TassyJim's solution should do the trick, but unfortunately it uses up to I/O pins on the micromite (the pins are connected together). cheers, rob :-) |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |