Shop OBEX P1 Docs P2 Docs Learn Events
Smart pin mode 01110 (periodic/continuous: increment on A-rise) strangeness — Parallax Forums

Smart pin mode 01110 (periodic/continuous: increment on A-rise) strangeness

The attached code will cause pin 1 to count the a-rises of pin 0, at about 100 per second, as output from debug.

If I change SP_SECTOR_UPDATE_TIMER to pin 1 instead of pin 0, pin 1 will still cycle, but pin 2 will not count the a-rises (the rdpin value is always 0). This seems to happen for any pin other than 0.

According to the documentation, pin selection %0101 selects the previous pin's input value. So in order for this to work for pins other than SP_SECTOR_TIMER = 0, I have to jumper that pin to the next pin. This fixes the issue with the counting.

But why does it work for pin 0 and 1 without the jumper? I have a eval board rev. B.

Comments

  • evanhevanh Posts: 15,915
    edited 2021-07-13 04:50

    The input select for the counter is set to -3 rather than intended -1. Which means, when on pins P0/P1, you are counting the tx data of debug output.

    I recommend start using the built-in symbols as per the Spin docs: eg: wrpin ##P_COUNT_RISES | P_MINUS1_A, #SP_SECTOR_UPDATE_COUNT

  • This works
    wrpin ##P_MINUS1_A | P_COUNT_RISES,#SP_SECTOR_UPDATE_COUNT

  • AJLAJL Posts: 517
    edited 2021-07-13 05:20

    Are you saying that it doesn't work for pin 3 counting the rises with SP_SECTOR_TIMER set to 2?
    From the current Parallax Propeller 2 documentation on p76:
    Below is a diagram of a single I/O pin circuit. It is powered from its local 3.3V supply pin. It connects to its own pin, as well as its odd/even adjacent pin. Pins P0 and P1 see each other's pins as adjacent pins, as do P2 and P3, etc.

    italics added.

    Edit: Not so relevant here. I only looked quickly while at work.

  • evanhevanh Posts: 15,915

    Three of us at once! :D

  • wmosscropwmosscrop Posts: 409
    edited 2021-07-13 13:51

    The value I used for the input selector is from the @JonTitus smart pin documentation (Smart Pins Rev 5).

    Page 6, under "WRPin"...

    "x101 = read state of P37 - 1 = P36, pin number minus 1"

    So it should be x111? Which does make more sense to me, being that all ones normally represents -1.

    Edit: For some reason I can't get the @JonTitus link to work.

Sign In or Register to comment.