microsecond counter in C
ccb214
Posts: 2
Hi im new in the parallax family, and well im trying to do a microsecond counter in C, but the only way that ive seen that they use the timer is with a given time
i was hoping some one could help me with any ideas on how to take the counter to start and stop when i tell it to, the first idea i had was to use the CLCKFREQ and use it to add up a counter... yet its still kinda fuzzy.
thank you
SincerelyCcb
i was hoping some one could help me with any ideas on how to take the counter to start and stop when i tell it to, the first idea i had was to use the CLCKFREQ and use it to add up a counter... yet its still kinda fuzzy.
thank you
SincerelyCcb
Comments
The CNT global register is free running. The alternative solution is to use the CNTA, FRQA, and PHSA registers (or CNTB ...). CNTA can be used to enable/disable the counter. The FRQA register can be set to toggle the "A pin" at end of the FRQA count. You should look at the latest Propeller Datasheet and/or the Counter App-note on the Parallax Propeller web-site download page. Maybe someone else can describe this in better detail for you. Your purpose is a little vague to me ... you might give an example of use.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propalyzer: Propeller PC Logic Analyzer
http://forums.parallax.com/showthread.php?p=788230
These counters can be started and stopped either under program control or an I/O pin.
The other option is to save the system clock value at the beginning of the time period and save another value at the end of the time period. By subtracting the two values, you get the elapsed time in system clock ticks (12.5ns at 80MHz). Since the counters are 32 bits, the maximum time period before wrapping around is around 50 seconds.
Thanks for your help [noparse]:D[/noparse]
http://www.rayslogic.com/propeller/PulseGen.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propalyzer: Propeller PC Logic Analyzer
http://forums.parallax.com/showthread.php?p=788230