If Wishes Were Horses (Question on P2 Counters)

JonnyMacJonnyMac Posts: 5,700
edited April 2 in Propeller 2 Vote Up0Vote Down
...we'd all be eating steak. (Jayne Cobb, "Firefly")

Admittedly, I've had no time to dive into the raging waters of the P2 design, only popping in from time-to-time to see what others are doing. Please forgive my ignorant question.

One of the things I like about the P1 counters is the ability to generate a precise pulse using NCO (%00100). What I'd really love is an NCO "one shot" mode. In my [fantasy] world, when the phsx hit 0 the accumulation of frqx into phsx would stop -- giving me a set-and-forget pulse output.

Is this possible in the P2, or am I showing my love of fantasy by quoting a fictional character misquoting a well-known phrase?
Jon McPhalen
-- please don't call me "Jonny"

Comments

  • 6 Comments sorted by Date Added Votes
  • I remember asking nicely for a one-shot mode and Chip put it in.
    But that was a few years ago...
    Prop Info and Apps: http://www.rayslogic.com/
  • I think this is the pulse mode from the P2 docs:
    %00100 = pulse/cycle output
    
    This mode overrides OUT to control the pin output state.
    
    X[15:0] establishes a base period in clock cycles which forms the empirical cycle time.
    
    X[31:16] establishes a value to which the base period counter will be compared to on each clock cycle, as it counts from X[15:0] down to 1, before starting over at X[15:0] if decremented Y > 0. On each clock, if the base period counter > X[31:16] and Y > 0, the output will be high (else low).
    
    Whenever Y[31:0] is written with a non-zero value, the pin will begin outputting a high pulse or cycles, starting at the next base period.
    
    Some examples:
    
    If X[31:16] is set to 0, the output will be high for the duration of Y > 0.
    
    If X[15:0] is set to 3 and X[31:16] is set to 2, the output will be 0-0-1 (repeat)  for the duration of Y > 0.
    
    IN will be raised when the pulse or cycles complete, with the pin reverting to low output.
    
    During reset (DIR=0), IN is low, the output is low, and Y is set to zero.
    

    These smart pins may be too smart for me to figure out though...
    Prop Info and Apps: http://www.rayslogic.com/
  • If nothing else, it looks like there's a set-and-forget PWM mode with fixed frequency (the SX had this and it was disappointed it didn't make it into the P1).

    Sometime soon I'm going to have to download the P2 files and start to play.
    Jon McPhalen
    -- please don't call me "Jonny"
  • If I'm reading it like I hope, then you can set Y=1 to get a single pulse.

    Funny if it turns out to be the same code (%00100) as P1...
    Prop Info and Apps: http://www.rayslogic.com/
  • :D Yeah.

    That time is rapidly approaching. Soon, SPIN 2 and C will be operational. Optimal Playtime.

    Do not taunt Happy Fun Ball! @opengeekorg ---> Be Excellent To One Another SKYPE = acuity_doug
    Parallax colors simplified: http://forums.parallax.com/showthread.php?123709-Commented-Graphics_Demo.spin<br>
  • evanhevanh Posts: 3,856
    edited April 3 Vote Up0Vote Down
    Smartpins are packing a lot of function and the flexibility makes the mode descriptions real eyes glazed over material. Here's an interesting, but now out-of-date, diagram Ariba skilfully made back when Smartpins was really taking shape - http://forums.parallax.com/discussion/comment/1366024/#Comment_1366024

    EDIT: Changed the link to the slightly later improved version.
    "Since 1978, the cost of textbooks has risen 812%, outpacing even the cost of medical services and new housing."
Sign In or Register to comment.