Shop OBEX P1 Docs P2 Docs Learn Events
Set/clear of OUTput pins — Parallax Forums

Set/clear of OUTput pins

HarleyHarley Posts: 997
edited 2007-07-25 22:00 in Propeller 1
Is there any Propeller instruction in assembly which will simultaneously affect output pins? I have several outputs which should only have one active at a time.

AND allows one to clear, OR to set. Is there any instruction that can force set and clear states to out pins? There doesn't seem to be any such instruction. Sure would be nice to have such. yeah.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
h.a.s. designn

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-07-25 16:56
    MUXC, MUXNC, MUXZ, MUXNZ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-25 17:11
    It sounds like you want to simultaneously change several different I/O pins to a pattern of 0/1 bits all at the same time. The closest thing would be to use an XOR instruction with one bits where you want to toggle the output pin and zero bits everywhere else. If IOMASK is the bit mask for the I/O bits involved and DESIRED is the I/O setting you want, try the following:
         mov    temp,outa
         xor      temp,DESIRED  ' Compute what bits you need to change
         andn   temp,IOMASK    ' Mask off the I/O bits of interest
         xor      outa,temp         ' Simultaneously change all the I/O pins involved
    
    
  • HarleyHarley Posts: 997
    edited 2007-07-25 17:24
    Mike said...
    It sounds like you want to simultaneously change several different I/O pins to a pattern of 0/1 bits all at the same time. The closest thing would be to use an XOR instruction with one bits where you want to toggle the output pin and zero bits everywhere else. If IOMASK is the bit mask for the I/O bits involved and DESIRED is the I/O setting you want, try the following:

    ·····mov····temp,outa
    ·····xor······temp,DESIRED··'·Compute·what·bits·you·need·to·change
    ·····andn···temp,IOMASK····'·Mask·off·the·I/O·bits·of·interest
    ·····xor······outa,temp·········'·Simultaneously·change·all·the·I/O·pins·involved

    Thanks, Mike. The above does it, though at the 'expense' of 3 instruction times; at 80 MHz system clock is an extra 150 nsec delay. Hopefully this delay can be tolerated.

    Paul, unfortunately, according to the Prop manual, MUXC, MUXNC, MUXZ, MUXNZ doesn't clear bits to '0'. I need to affect the individual bits to either HI or LO simultaneously.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
    h.a.s. designn

    Post Edited (Harley) : 7/25/2007 5:31:22 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-25 17:42
    Harley,
    If this is running in its own cog and there are no other output pins involved, you can dispense with the ANDN since each cog has its own DIRA register and you can just enable only those bits you want to be outputs. Also, the OUTA bits not involved with this will be zero. Similarly, if DESIRED is computed every time, you can do:
         xor DESIRED,outa
         xor outa,DESIRED
    
    
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-07-25 17:50
    Harley, those instruction copy the contents of the carry or zero flag. Since these flags can be either state, it is possible to either set or clear the targeted bits.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • HarleyHarley Posts: 997
    edited 2007-07-25 19:16
    Paul said...
    Harley, those instruction copy the contents of the carry or zero flag. Since these flags can be either state, it is possible to either set or clear the targeted bits.
    However, not to 'both' states (say ...110 to ...101) simultaneously, right? I'm trying to replace loads of TTL logic with a Prop. And cannot allow enabling two or three 8-bit gates on a bus. Nor disable all terms on bus at a given time.

    What I was hoping for was a 'set/clear' operation rather than a 'set' or 'clear' on several output lines.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
    h.a.s. designn
  • deSilvadeSilva Posts: 2,967
    edited 2007-07-25 19:35
    I cannot fully assess the timing constraints involved, but there is always the simple MOV instruction.
    There is no danger to influence anything not enabled by the local DIRA register.

    Also, be carefull with read-modify-write cycles on I/O registers at dest-position.
  • HarleyHarley Posts: 997
    edited 2007-07-25 20:05
    Thanks Mike,

    Looks like the 'two XORs' does the desired result. Dang tricky, those XORs.

    Appreciate the solution. I'd seen something like this before but didn't understand what the point was. After doing a few examples on the combinations involved in this application, it is quite clear. yeah.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
    h.a.s. designn
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-25 20:13
    deSilva is right in that a MOV to OUTA will often work for this situation.· The XOR solution is necessary if some of the output bits are to be changed in one routine and some other output bits are to be changed in some other routine, both in the same cog.· The MOV will change all of the bits all of the time.· The XOR will only change the bits that need changing at that time.
  • deSilvadeSilva Posts: 2,967
    edited 2007-07-25 20:27
    Mike Green said...
    The MOV will change all of the bits all of the time. The XOR will only change the bits that need changing at that time.
    Mike, don't split hairs!
  • HarleyHarley Posts: 997
    edited 2007-07-25 21:44
    I can understand how XOR can affect bits, but how does one use MOV to only affect selected few bits to change to desired states simultaneously w/o affecting all bits?

    I'm missing something here with no masking happening.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
    h.a.s. designn
  • Mike GreenMike Green Posts: 23,101
    edited 2007-07-25 22:00
    Harley and deSilva,
    I'm not splitting hairs. I'm talking about a functional difference. A MOV instruction changes all 32 bits of the destination to a new 32 bit value. The MOV may be part of a larger program and the new 32 bit value may be an amalgam of several sources. The XOR modifies an existing value, changing only some of the bits. Any bits corresponding to zero bits in the source are left unchanged in the destination. Now the instruction cycle does go through a source and destination fetch, modification, and destination store, so the whole contents of the destination does get set to the result of the instruction execution. From the standpoint of the programmer and the actual instruction, known, anticipated bits of the destination are not changed. In the case of OUTA, there will be no glitches on any output pins where zero bits exist in the source field.
Sign In or Register to comment.