Shop OBEX P1 Docs P2 Docs Learn Events
TAQOZ pin state and assignment — Parallax Forums

TAQOZ pin state and assignment

VonSzarvasVonSzarvas Posts: 3,450
edited 2019-01-03 16:49 in Propeller 2
Looking for help with TAQOZ. Seems like a neat way to test some P2 boards if this can work !


I'm trying to read a pin with this code:
33 PIN@ .

And getting these 3 replies, based on state.
TAQOZ# 33 PIN@ . 0 ok
TAQOZ# 33 PIN@ . -1 ok
TAQOZ# 33 PIN@ . -1 ok

0 when pin 33 is grounded, -1 when floating or high.

Is there some way to differentiate between floating and high ?



Also, about assignment. Is there a shorthand to set the output state of one pin according to the input value on another pin ?

I was doing this:
3 NEWCOG
: TESTAV BEGIN 33 PIN@ 0= IF 56 HIGH ELSE 56 LOW THEN AGAIN ;
' TESTAV 3 TASK W!

But I figured it could be simpler if the value of 33 PIN@ could be assigned to pin 56 directly. Is that possible ?

Quasi-code here...
Something like: 33 PIN@ > PIN 56
Reason being, then it could be looped, maybe along the lines of: 8 0 DO PIN I = I+1 PIN@ I++ LOOP
So set the first 4 pins to be the values of the neighbors. (yeah- it's a stinker of an effort that quasi code!)

Comments

  • Cluso99Cluso99 Posts: 18,069
    To test for a floating pin it's necessary to pulse the pin and then read it back quickly before it floats back to its normal state, but slow enough to allow for a pull-up/pulldown to take effect. For this we really need to know the operating frequency and the values of pull-up/pulldown or if it's being driven to design a foolproof test.
    From what we found with the P2D2 not all pins read the same when floating, unlike the P1 which always reads low when floating.
    I am sure Peter can work out a sequence for you.
  • Thanks. The pin goes out on a series 470R through a tactile up to 3V3. There is no pullup or down. The series R means the pin could be driven as you suggest, then scanned for state.
    Freq. not especially fast. 50ms would probably be excessive.

    The test code wants to replicate the button state on an LED (which is driven high on the P2 side and tied to gnd via another series R).

    This explains the thought about setting the LED state directly from the button state, as high on the button would have the LED lit.
    There's 4 buttons (pin 0,1,2,3) with 4 LEDs (pin 4,5,6,7) that could be scanned in a loop if direct assignment is possible. But that's not a deal-breaker.

    I'll try adjusting the code to pulse that pin low for 1ms before reading the state- that might do the trick!


  • Don't forget the rather useful "lsio" command that reports back the state of the pins and is very useful for checking hardware.
    TAQOZ# lsio 
    P:00000000001111111111222222222233333333334444444444555555555566
    P:01234567890123456789012345678901234567890123456789012345678901
    =:ddd~d~~~~~~ddd~ddd~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~h ok
    

    The newer version of TAQOZ which I boot from SD card reports back a little more information such as H for a high output or h for a high input etc.
    TAQOZ# lsio 
    P:0000000000111111111122222222223333333333444444444455555555556666
    P:0123456789012345678901234567890123456789012345678901234567890123
    ?:lllllhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhHhHL
    =:ddddd~~~~~~ddd~ddd~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~u~uu ok
    

    TAQOZ should really have a PIN! to match the PIN@ but of course you can just create one.
    : PIN! ( state pin -- ) SWAP IF HIGH ELSE LOW THEN ;
    
  • jmgjmg Posts: 15,173
    Expanding this, how can TAQOZ be used to access Smart pins & report serially.

    Taking an example, of measure SysCLKs needed for (eg) 2e6 _/= edges on Pin31 ?
    I think that is this in the DOCs ( X=2e6, Y = %00)

    %10011 = For X periods, count time
    %10100 = For X periods, count states

    X[31:0] establishes how many A-input rise/edge to B-input rise/edge periods are to be measured.

    Y[1:0] establishes A-input and B-input rise/edge sensitivity:

    %00 = A-input rise to B-input rise
    %01 = A-input rise to B-input edge
    %10 = A-input edge to B-input rise
    %11 = A-input edge to B-input edge

    Note: The B-input can be set to the same pin as the A-input for single-pin cycle measurement.

    Clock cycles or A-input trigger states are counted from each A-input rise/edge to each B-input rise/edge for X periods. If the A-input rise/edge is ever coincident with the B-input rise/edge at the end of the period, the start of the next period is registered. Upon completion of X periods, the measurement is placed in Z, IN is raised, and a new measurement begins. RDPIN/RQPIN can then be used to retrieve the completed measurement. Z will be limited to $80000000.

    The first mode is intended to be used as an oversampling period measurement, while the second mode is a complementary duty measurement.

    During reset (DIR=0), IN is low and Z is set to $00000000.


    Result will be about 25M for 250MHz sysCLK, if 20MHz is applied to pin31

    Can that print in a simplest spread sheet/terminal compatible manner - eg one number per line, whole decimal int32?
Sign In or Register to comment.