Shop OBEX P1 Docs P2 Docs Learn Events
setp, clrp, etc. Still work like preliminary info? — Parallax Forums

setp, clrp, etc. Still work like preliminary info?

RaymanRayman Posts: 14,755
edited 2013-04-01 00:36 in Propeller 2
In the new documentation, I don't see setp, clrp, etc. mentioned... Did I miss something?

I only see them in Propeller2DetailedPreliminaryFeatureList-v2.0.pdf , but I've found that some of that info is outdated and no longer accurate...

Is the section titled "Ports" in the above still accurate?

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-30 10:32
    Rayman wrote: »
    In the new documentation, I don't see setp, clrp, etc. mentioned... Did I miss something?

    I only see them in Propeller2DetailedPreliminaryFeatureList-v2.0.pdf , but I've found that some of that info is outdated and no longer accurate...

    Is the section titled "Ports" in the above still accurate?
    I'm using them and they seem to be working so I guess they're still there! :-)
  • RaymanRayman Posts: 14,755
    edited 2013-03-30 10:38
    I hope Chip can provide assurance on this. He has provided a lot of detail on the advanced instructions, but I don't see any updates on the basic ones.



    Maybe that means they haven't changed. But, I found out the something with cnt has changed...
  • AribaAriba Posts: 2,690
    edited 2013-03-30 10:59
    Yes setp and such simplifies working with single Port Pins a lot. You don't need to set the DIRx register, this is done automatically, and you can access all the pins without knowing on which port (A,B,C) they are.

    Attached is the full instruction set that Chip once posted. It contains only the instructions without explanations. I normally check if an instruction from the Preliminary Document is still in this list, then I assume the decription is still correct...

    Andy
  • RaymanRayman Posts: 14,755
    edited 2013-03-30 13:40
    Are you saying that setp affects the corresponding direction too? I didn't know that...

    I wonder if offp really toggles dir then or just turns it off...
  • David BetzDavid Betz Posts: 14,516
    edited 2013-03-30 13:44
    Rayman wrote: »
    Are you saying that setp affects the corresponding direction too? I didn't know that...

    I wonder if offp really toggles dir then or just turns it off...
    I think offp may turn off output on that pin. It's notp that toggles it I think.
  • RaymanRayman Posts: 14,755
    edited 2013-03-30 13:50
    That would be nice... But, that pdf says this fir offp:



    Toggle pin number given by register




  • SapiehaSapieha Posts: 2,964
    edited 2013-03-30 13:54
    Hi Rayman
    Table 16: ''Pin State Access Instructions
    
    Machine Code                            |   Mnemonic    |   Operand |   Operation
    ----------------------------------------------------------------------------------------------
    000011 ZCN 1 CCCC DDnnnnnnn 011010110   |   GETP        |   D/#n    | Get pin number given by register “D (0-511)”
                                                                        | or “n (0-127)”into !Z or C flags. (pin into !z/c via wz/wc)
                                                                        | (pin into !z/c via wz/wc)
    000011 ZCN 1 CCCC DDnnnnnnn 011010111   |   GETNP       |   D/#n    | Get pin number given by register “D (0-511)”
                                                                        | or “n (0-127)”into Z or !C flags. (pin into z/!c via wz/wc)
                                                                        | (pin into z/!c via wz/wc)
    000011 ZCN 1 CCCC DDnnnnnnn 011011000   |   OFFP        |   D/#n    | clears both the DIR bit and PIN bit for the pin
                                                                        | (input with output bit low)
    000011 ZCN 1 CCCC DDnnnnnnn 011011001   |   NOTP        |   D/#n    | Invert pin number given by the value in register “D (0-511)”
                                                                        | or “n (0-127)”. OUT
    000011 ZCN 1 CCCC DDnnnnnnn 011011010   |   CLRP        |   D/#n    | Clear pin number given by the value in register “D (0-511)”
                                                                        | or “n (0-127)”. OUT
    000011 ZCN 1 CCCC DDnnnnnnn 011011011   |   SETP        |   D/#n    | Set pin number given by the value in register “D (0-511)”
                                                                        | or “n (0-127)”. OUT
    000011 ZCN 1 CCCC DDnnnnnnn 011011100   |   SETPC       |   D/#n    | Set pin number given by the value in register “D (0-511)”
                                                                        | or “n (0-127)” to C.
    000011 ZCN 1 CCCC DDnnnnnnn 011011101   |   SETPNC      |   D/#n    | Set pin number given by the value in register “D (0-511)”
                                                                        | or “n (0-127)” to !C
    000011 ZCN 1 CCCC DDnnnnnnn 011011110   |   SETPZ       |   D/#n    | Set pin number given by the value in register “D (0-511)”
                                                                        | or “n (0-127)” to !Z.
    000011 ZCN 1 CCCC DDnnnnnnn 011011111   |   SETPNZ      |   D/#n    | Set pin number given by the value in register “D (0-511)”
                                                                        | or “n (0-127)” Z.
    Chip:
    OFFP D/#n - clears both the DIR bit and PIN bit for the PIN (input with output bit low) 
    GETP and GETNP do not affect the DIR bit. They only read the input, regardless of its DIR state. In other words,
     if a PIN is outputting a low, but is externally being forced high, you will read the high state. 
    
    Only a read-modify-write (or a write) to a PINx register will affect the output latches.
     A read-without-write will read the pins'' input states, not the output latches.
     This is an unintended consequence of getting rid of discrete IN and OUT registers - it is not an issue in assembly,
     but it is in high-level languages. 
    
    Read/modify/write instruction reads the output latches instead of the input state.
     
    If you use one of the pin output instructions (SETP, CLRP, NOTP ...) the direction is automatically set to output,
     you don''t need to set DIRx first.
     So: Yes there is another way beside setting DIRx.
    
    Rayman wrote: »
    That would be nice... But, that pdf says this fir offp:

    Toggle pin number given by register


  • SapiehaSapieha Posts: 2,964
    edited 2013-03-30 14:01
    Hi.


    Previous post edited
  • RaymanRayman Posts: 14,755
    edited 2013-03-30 14:29
    Ok, that sounds pretty good then.
    Actually, does getp not give you actual input, only output setting?
  • pedwardpedward Posts: 1,642
    edited 2013-04-01 00:36
    According to the doc, you have it backwards. GETP reads the physical pin state, ahead of the muxes that go to each COG.

    It also appears, with the eschewing of the discrete IN/OUT registers, there is no way to read the output latch for the pins, any read instruction only reads the physical input state. I'm sure there are some cases where this is undesirable, but it seems to align the P2 with conventional micros, insomuch as you don't need to address 2 registers to perform bidirectional I/O.
Sign In or Register to comment.