Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:57 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : high-resolution timer/counter?

Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 03:59pm 28 Jun 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2170
Posted: 09:05pm 28 Jun 2020
Copy link to clipboard 
Print this post

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: Netherlands
Posts: 5091
Posted: 07:06am 29 Jun 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 1329
Posted: 12:51pm 29 Jun 2020
Copy link to clipboard 
Print this post

@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 Zealand
Posts: 2442
Posted: 08:08pm 29 Jun 2020
Copy link to clipboard 
Print this post

  CaptainBoing said  As far as fast count inputs go, would 20MHz do ya?

https://www.thebackshed.com/forum/ViewTopic.php?TID=10813


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   :-)
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025