Shop OBEX P1 Docs P2 Docs Learn Events
Smartpin mode to replicate the Prop1's counter mode %11010 LOGIC A — Parallax Forums

Smartpin mode to replicate the Prop1's counter mode %11010 LOGIC A

I have a project I wrote many many moons ago that used the Propeller 1's Counter to accumulate the High time on a pin.

I read that the Prop 2 does not have the same kind or any counters.

Can this functionality be done with the Propeller 2's smart pins?

Comments

  • Certainly can, you want this smartpin mode, from the google docs

    --
    %01111 AND !Y[0] = Count A-input highs
    %01111 AND Y[0] = Increment on A-input high and decrement on B-input high

    X[31:0] establishes a measurement period in clock cycles. Y[0] establishes whether to just count A-input highs (=0), or to increment on A-input high and decrement on B-input high (=1).

    If zero is used for the period, the measurement operation will not be periodic, but continuous, like a totalizer, and the current 32-bit high count can always be read via RDPIN/RQPIN.

    If a non-zero value is used for the period, events will be counted for that many clock cycles and then the result will be placed in Z, while the accumulator will be set to the 0/1/-1 value that would have otherwise been added into it, beginning a new measurement. This way, all events get counted across measurements. At the end of each period, IN will be raised and RDPIN/RQPIN can be used to retrieve the 32-bit measurement.

    During reset (DIR=0), IN is low and Z is set to the adder value (0/1/-1).
  • jmgjmg Posts: 15,140
    The smart pins docs really do need fleshing out...
    eg Suppose you have Count A-input highs fed from a signal that is 9999 HI and 1 LOW.
    Can P2 read that 'as expected' and not need any pin-level-polling to prime and read the counters, as needed in P1.
Sign In or Register to comment.