Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:09 04 Dec 2024 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 : COUNT and max frequency for PicoMite?

     Page 2 of 2    
Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2152
Posted: 12:36pm 23 Nov 2024
Copy link to clipboard 
Print this post

If Jim's method is fast enough for your needs it will give you 10^12 counts. That is a lot!

While awaiting Peter's update I think this will give 62 or 63 bits starting from 0.
setpin gp0,pwm : pwm 0, 1000000,50
setpin gp6,cin
> pin(gp6)= -(2^31) :pause 10000 : C=pin(gp6)+(2^31) :? C

At 1MHz it will take a much longer than the 10 seconds in the above example (years I imagine) to reach 2^62.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6110
Posted: 07:26pm 23 Nov 2024
Copy link to clipboard 
Print this post

  phil99 said  
At 1MHz it will take a much longer than the 10 seconds in the above example (years I imagine) to reach 2^62.


53375996 days or 146236 years approximately

While Peter has now given us 64 bit (signed I assume) counts, there are plenty of external devices that are 16 or 32 bit or any strange number of bits that will need converting to MMBasic integers.
VK7JH
MMedit   MMBasic Help
 
ElectroPI
Newbie

Joined: 27/04/2012
Location: Australia
Posts: 36
Posted: 10:27am 24 Nov 2024
Copy link to clipboard 
Print this post

Having it the same as a (signed?) integer would be great and saves confusion. Thanks Peter for including this in your next update.

all the best
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9182
Posted: 10:40am 24 Nov 2024
Copy link to clipboard 
Print this post

NB:
The fast timer functionality is RP2350 only. This is because only the RP2350 has a second PWM interrupt and this is needed for the 16-bit PWM register rollover. The first interrupt is dedicated to audio.
RC17 has the 64-bit counter variables
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 886
Posted: 02:34pm 25 Nov 2024
Copy link to clipboard 
Print this post

  matherp said  In the latest release you can use pin GP1 for very fast frequency measurement

SETPIN GP1,FFIN ' set GP1 for fast frequency input
'Connect gp1 to gp3
SETPIN GP3,PWM
PWM 1,val(mm.info(cpuspeed))/4,,50 'this is the fastest PWM can run
? pin(gp1)


Only just made it back to my desk to test this  

Many thanks Pete, works beautifully  
 
     Page 2 of 2    
Print this page


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

© JAQ Software 2024