Accessing the P2 system counter in Spin?
Martin Hebel
Posts: 1,239
Hi All,
Long time no play with the propeller chips.
How can I access the system counter via spin? I see an example using cnt, but when I compile it says it needs to be defined?
https://www.parallax.com/propeller/qna-mobile/Advanced/Content/CodeTeqTopics/CodeExeTime.htm
Thanks for the easy help. It's been a long night coming up to partial speed again with it after a prolonged break, where once I was a tester/early developer for the original Propeller, now I've forgotten nearly everything!
-Martin
Comments
On the P2 use getct(), for example create a variable called Count and do the following:
Count := getct()
Thanks! Very Java-esq.
Welcome back, Martin. There is a lot to like with the P2, and Spin2 is very nice. If you don't need system tick resolution, you can get the current milliseconds since reboot with
Or, if you want to go the other way, you can use P2's inline assembly feature to get all 64 bits of the system counter (returned as two longs)
I've attached a Spin2 template that you might find useful as you come back up to speed.
Thanks Jon,
I've gotten the new fullduplexserial going, but I will say it threw me an error on a variable called field. Apparently that's a keyword now? So I changed it something else and it worked fine.
-Martin
Yeah, that's happened twice: Chip updated the compiler with new keywords that trampled on method or variable names in jm_fullduplexserial. My latest is in that template archive (it compiles fine with Propeller Tool 2.9.3). The upside of all of this is that, unlike the P1 which had the interpreter frozen in silicon, Spin2 includes the interpreter code in the download which means it can be -- and has been -- updated.
Once we have ObEx restored, I can keep my code updated online.
Thanks for the great libraries Jon, using the P2 to drive my MakerPlot-J software to display a 1KHz sine wave.
Neat; I'm glad I could lend a hand.