122-32000 Parallax Inc, 122-32000 Datasheet - Page 184

MANUAL PROPELLER

122-32000

Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Datasheets

Specifications of 122-32000

Accessory Type
Manual
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
CNT
System Counter register.
((PUB ┆ PRI))
Returns: Current 32-bit System Counter value.
Explanation
The
Counter serves as the central time reference for all cogs; it increments its 32-bit value once
every System Clock cycle.
Upon power-up/reset, the System Counter starts with an arbitrary value and counts upwards
from there, incrementing with every System Clock cycle. Since the System Counter is a
read-only resource, every cog can read it simultaneously and can use the returned value to
synchronize events, count cycles and measure time.
Using CNT
Read
any particular purpose, but the difference in successive reads is very important. Most often,
the
the start of a window of time. The next examples use the
The above code is an example of a “fixed delay.” It delays the cog’s execution for 3 million
system clock cycles (about ¼ second when running with the internal fast oscillator).
The next is an example of a “synchronized delay.” It notes the current count at one place and
performs an action (toggles a pin) every millisecond thereafter with accuracy as good as that
of the oscillator driving the Propeller chip.
PUB Toggle | TimeBase, OneMS
Page 184 · Propeller Manual v1.0
CNT
waitcnt(3_000_000 + cnt)
dira[0]~~
OneMS := clkfreq / 1000
TimeBase := cnt
repeat
CNT
CNT
waitcnt(TimeBase += OneMS)
!outa[0]
CNT
– Spin Language Reference
register is used to delay execution for a specific period or to synchronize an event to
register contains the current value in the global 32-bit System Counter. The System
to get the current System Counter value. The actual value itself does not matter for
'Wait for 3 million clock cycles
'Set P0 to output
'Calculate cycles per 1 millisecond
'Get current count
'Loop endlessly
' Wait to start of next millisecond
' Toggle P0
WAITCNT
instruction to achieve this.

Related parts for 122-32000