P2 SPIN read CNT
pic18f2550
Posts: 400
in Propeller 2
How can I read out the cnt?
In PASM this is clear to me, but to spin I find nothing in the documentation.
sync := cnt {{ Alle COGs Starten }}
Comments
GETCT()
Thank you
As Roger pointed out, retrieving the cnt register in Spin2 is different. Likewise, waiting for a specific count is, too.
You can find the changes and new features in the timing section of the built-in functions part of the doc.
I wonder if it would be possible to return the low long AND the high long. In PASM2 it is possible to get the full 64 bit counter value.
Now that we have multiple return values, it should be possible to do
highct, lowct := getct()
... only has to be build into the SPIN2 interpreter I guess.
For the time being, you could inline it. I did this when getms() disappeared.
@JonnyMac
Hmmm ... looks like a solution ... or THE solution .. thanks.
Because of that it is probably not worth to get into trouble with usage of
waitct( getct() + x )
Well .. well .. sometimes tomatoes are, where they should not be )
( Is it a valid phrase in english? We say "having tomatoes on the eyes" in case you miss to see the obvious )
I have no great command of English, but we don't generally use tomato as a verb -- we'd usually say, "If some throws a tomato at me..."
A common English phrase is 'can't see the forest for the trees' for when you get caught up in the details, so you don't see the bigger picture.
The simple reading of the 32bit values brings a lot of errors.
Because every 32bit overflow inevitably brings a new value in the Hi part.
With 256Mhz this would happen every 16 seconds.
With the Lo query, would have to be buffered for the next Hi query.
All sorted with Jon's getct64() above. The paired instructions return an "atomic" snapshot of the 64-bit counter.