Question on the Counter Module
Hi, I was reading the Counter Modules and Circuit Applications PE Lab,
on page 6, it says that between phsa~ and dira[noparse][[/noparse]17]~, there are 624 cycles.
Shouldn't that number depend on clkfreq?
on page 6, it says that between phsa~ and dira[noparse][[/noparse]17]~, there are 624 cycles.
Shouldn't that number depend on clkfreq?

Comments
is the easiest one to understand. The number 624 was
strange to me because phsa~ and dira[noparse][[/noparse]17]~ seemed
like simple bit operations. I would think that it would take
less than 10 cycles to execute if done in assembly. It is
that much slower using the interpreter?
It also seemed that the manual was using 624 as a time
value instead of a cycle value:
Counter Module PE Lab Manual wrote on page 6:
Where did 624 come from?
The number of clock ticks between phsa~ and dira[noparse][[/noparse]17]~ was determined by replacing the 0.01 μF
capacitor with a 100 pF capacitor and finding the lowest value before zero was returned. In the test program,
time := phsa replaces time := (phsa – 624) #> 0, and the lowest measurable value was 625.
The code:
PUB Main | time '' Repeatedly takes and displays P17 RC decay measurements. repeat ' Charge RC circuit. dira[noparse][[/noparse]17] := outa[noparse][[/noparse]17] := 1 ' Set pin to output-high waitcnt(clkfreq/100_000 + cnt) ' Wait for circuit to charge ' Start RC decay measurement. It's automatic after this... phsa~ ' Clear the phsa register dira[noparse][[/noparse]17]~ ' Pin to input stops charging circuit ' Optional - do other things during the measurement. Debug.str(String(10, 10, 13, "working on other tasks")) repeat 10 Debug.tx(".") waitcnt(clkfreq/30 + cnt) ' Measurement has been ready for a while. Adjust ticks between phsa~ & dira[noparse][[/noparse]17]~. time := (phsa - 624) #> 0 ' Display Result Debug.Str(String(10, 13, "time = ")) Debug.Dec(time) waitcnt(clkfreq/2 + cnt)My confusion is that if 624 was just the number of cycles
of the interpreter, then the test with capacitance was
probably irrelevant. If the capacitance test was relevant,
then 624 corresponded to a duration, but the unit of
624 was in clock ticks.
Post Edited (Edgar) : 3/24/2008 5:51:16 AM GMT
This particular lab illustrates how you can measure the time using an RC circuit. The time is measured in clock ticks because there's a built-in timer that's incremented every clock tick. I'm sure this lab is written this way because it's designed to work with different Propeller boards and some of them come with clock crystals that produce a different system clock frequency.