Thursday, 19 December 2013

Multiplexing high frequency digital signals using a Parallax Propeller

While contemplating the Counter features of the Propeller chip, an interesting idea occurred to me.  Since each "Cog" has it's own CTRA and CTRB counters, and given that they run at the system clock (after PLL) speed AND run "in the background" without requiring any particular interaction with running code....

It should be possible to feed in a high(ish) frequency digital signal into an input pin and arrange the CTRA/CTRB features such that the signal is redirected out of an output pin with very little latency and without needing to execute any instructions at all (apart from a small number to set up the features to begin with).

Furthermore, one input pin could supply both CTRA and CTRB simultaneously while two outputs are driven (one for each CTRx).

Even more furthermore, I theorise (but have not yet implemented) that all 16 CTRx features in a Propeller could feed from a single input pin and supply 16 output signals simultaneously!!!

The output signal would be inverted and one master clock cycle behind the input signal.  If multiple output signals are generated, then they would all be exactly in phase with eachother (but still inverted and trailing slightly behind the input signal).

"This doesn't sound very useful!" I hear you cry.  Well it could be used for the following purposes:

  1. Re-routing UART data to alternative destinations, or multiple destinations.  You'd simply need to re-invert the inverted outputs to get your signal the right side up but this is cheap to do.
  2. Clock distribution without having to use expensive additional components.
  3. Simply inverting a digital signal.
  4. All of the above at up to 80MHz (or more if you like overclocking your Propeller)!
Even if you do have 16 outputs running at a time, you'll still have 12 IO pins (16 minus the pin used for programming the chip and I2C to the EEPROM) free to do other stuff with and you're still not actually running a single instruction of code yet.  The only code involved is run once and it only involves setting a couple of registers, but after that your code can forget all about what its counters are up to and get on with other things.


  1. Wardy,

    I don't follow how this would work, maybe I just need some code to look at.

  2. Each CTRx has a pait of bit fields to indicate "A" and "B" pins. Then set CTRA to use "POS Detect with feedback" (see the Propeller Manual for how to do that). PHSA and FRQA can both be ignored or set to zero as this method doesn't use them.

    Then have your cog sleep forever (waitpeq $, #0), the CTRA will sit happily running forever, inverting the signal on the A pin and outputting it on the B pin.

    I'll throw together a code example later on.