A Counter Module (also known as a Counter) is a cog's configurable state machine for generating or sensing repetitive signals. Each cog has two independent counter modules, Counter "A" and Counter "B."
The counter modules provide simple, flexible subsystems for each cog to perform repetitive tasks on potentially every clock cycle; they can often take the place of dedicated peripheral driver hardware, reducing component count in an application.
Counters can provide a cog with a variety of services. These can be used to:
The counter modules are just adders that are activated on potentially every clock cycle when a certain condition is true. The result of the addition can affect the state of one or two I/O pins, and both the result and the I/O pin reaction can optionally be monitored by the program running in the cog.
Each counter module (A or B) is configured through a its Counter Control Register (CTRA or CTRB) to set its operating mode, optional time divisor, and I/O pin usage. Afterwards, the counter module hardware runs automatically, adding the value from its Frequency Register (FRQA or FRQB) to its Phase Register (PHSA or PHSB) on every clock cycle when its mode-defined condition is true.
The counter can be left to run autonomously, or can be monitored and adjusted by the cog's running program to achieve advanced effects.
There are 32 counter modes, including "off" (disabled). The 31 active counter modes are grouped into six categories, each accumulates (from FRQ to PHS) whenever the designated condition is true.
Yes! Once configured by program code, the counter modules operate independently while the cog performs other tasks. The program code can monitor the work of the counter module at any time without interrupting it by reading the appropriate special purpose register in its Cog RAM.
No. A cog's counter modules can only interact with the code being executed by that specific cog. Likewise, the cog's special purpose registers can only be read by code being executed within that cog.
Yes! That is one of the benefits of the software-reconfigurable counter modules. Instead of requiring a dedicated internal or external hardware device, an application can use a counter module to perform a temporary task, then release those resources for another use later, or shut them down to save power.
Yes. Video generation requires the use of the cog's Video Generator and the Counter A module; the Counter B module is still available for use.
Propeller P8X32A Questions & Answers
Copyright © Parallax Inc., dba Parallax Semiconductor
Version 1.3.1
10/23/2013