Shop OBEX P1 Docs P2 Docs Learn Events
Understanding DIRA and OUTA in multiple cogs — Parallax Forums

Understanding DIRA and OUTA in multiple cogs

Mark SwannMark Swann Posts: 124
edited 2007-11-05 06:56 in Propeller 1
I thought I knew how to use dira and outa, but I am seeing some strange behavior in some code I am testing. So, let me pose this question.

If, in cog 1, I set all bits in dira to zero, and in cog 2 I set 1 or more bits of dira to '1', will writing 1's into outa of cog 1 affect any of the output pins?

Lucidman


Post Edited (lucidman) : 11/5/2007 2:02:07 AM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-11-05 02:29
    No. The only pins affected by OUTA are those whose DIRA bits are also set in the same cog.

    -Phil
  • Mark SwannMark Swann Posts: 124
    edited 2007-11-05 02:59
    Phil Pilgrim (PhiPi) said...
    No. The only pins affected by OUTA are those whose DIRA bits are also set in the same cog.

    -Phil
    I thought so. Hmm. Let me describe my problem.

    I took the uOLED-96-Prop-Demo_V4.spin demo program and modified it to launch a cog with some assembly code in it. The new cog would write some things to the four outputs P18, P19, P20 and P21. The problem is that it causes the graphics module to stop displaying what I commanded it to display, i.e it goes blank.

    Here is the assembly code in the new cog that I started with.
                            org
    entry
                            mov     dira, setup_bits_a
    loop
                            mov     t1, t2
                            shl     t1, #18
                            mov     outa, t1
                            add     t2, #1
                            jmp     loop
                                    '33222222 22221111 11111100 00000000
                                    '10987654 32109876 54321098 76543210
    setup_bits_a            long    %00000000_00111100_00000000_00000000
    t1                      long    0
    t2                      long    0
    

    So I decided to try something strange. I set all the dira bits to zero, and it still causes the graphics module to go blank. Go figure!
                            org
    entry
                            mov     dira, #0
    loop
                            mov     t1, t2
                            shl     t1, #18
                            mov     outa, t1
                            add     t2, #1
                            jmp     loop
    t1                      long    0
    t2                      long    0
    

    ·Furthermore, if I change the·code so it only writes zeroes to outa, it works fine, The screen does not go blank. Again, go figure.

    I'm baffled.

    Any ideas?

    (not so) Lucidman
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-05 03:11
    The problem may have something to do with the JMP destination being incorrect. It should be JMP #loop. It's probably jumping off to t2 (whose address is in the source field portion of the location at loop) which doesn't do anything if it's zero, but the locations in hub memory that follow t2 may contain all sorts of stuff that might end up changing DIRA.
  • Mark SwannMark Swann Posts: 124
    edited 2007-11-05 03:15
    Mike Green said...
    The problem may have something to do with the JMP destination being incorrect. It should be JMP #loop. It's probably jumping off to t2 (whose address is in the source field portion of the location at loop) which doesn't do anything if it's zero, but the locations in hub memory that follow t2 may contain all sorts of stuff that might end up changing DIRA.
    Doh! I can't believe I did that. I know better. I'll fix it and give it a try.

    Thanks,

    Lucidman
    ·
  • Mark SwannMark Swann Posts: 124
    edited 2007-11-05 03:24
    Mike,

    You da man!

    That was the problem.

    Thanks

    Lucidman.
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-11-05 05:20
    I thought the data directions were OR'd like the outputs, i.e., if one cog sets a pin to output, it's an output. But you're saying that even though this is true, a cog can not output unless its own pin direction is set to output?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-05 05:51
    Ken,
    When in doubt, refer to the datasheet! If you'll notice on the diagram of the cogs that shows the I/O chain, the output of each cog is conditioned by the direction register. If the direction register bit in the cog is zero, the output of the cog will be forced to zero regardless of the value in the output register.
  • deSilvadeSilva Posts: 2,967
    edited 2007-11-05 06:56
    Additional to the detailed architectural diagram, there is a most explicite explananation in the Manual (Chapter 1); deSilva also maneged to describe it in a shorter section in his Tutorial smile.gif

    Reading pays!
Sign In or Register to comment.