Shop OBEX P1 Docs P2 Docs Learn Events
Can a COG access another COG's DIR? — Parallax Forums

Can a COG access another COG's DIR?

ProcessingData...ProcessingData... Posts: 208
edited 2009-04-18 02:59 in Propeller 1
I built a program that would display a 1 if pin 0 was an input, and 0 if it was an output. I tried it, it worked fine while the DIRA command was in the same cog, but when tried with a different COG changing the DIR, it wouldn't work. So, I referred to the trusty Propeller Manual. In it it said that each COG keeps it's own DIR register, which is OR-ed (or OR'd?) with the other COGs. Is there any way that·I can, from one COG, copy the DIR register from another COG at any given time?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Basic Stamp,···· Propeller,·· · SX,·· FUN!


START:·
>Proccessing Data. . . .··
>Task Complete. . .·.
>Saving Data. . . .
>Entering SLEEP Mode. . . .
>Signing OFF


·

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-04-17 22:59
    You'd have to pass the value via a hub RAM location, i.e. Program A reads its DIRA and writes that value to the hub. Program B (in a different cog) reads this value from the hub and does whatever with it.

    -Phil
  • ProcessingData...ProcessingData... Posts: 208
    edited 2009-04-17 23:07
    Any other way? I'd like to read it at any given time, in any COG, from any COG, without adding code to the other program.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Basic Stamp,···· Propeller,·· · SX,·· FUN!


    START:·
    >Proccessing Data. . . .··
    >Task Complete. . .·.
    >Saving Data. . . .
    >Entering SLEEP Mode. . . .
    >Signing OFF


    ·
  • MagIO2MagIO2 Posts: 2,243
    edited 2009-04-17 23:11
    Why would you need that?
    Usually you should know which COG uses which PINs. That's why each and every object in the ObEx should define a constant like basepin or constants where you can configure the pin numbers. And lesson one for propeller programmers should be: check the setup of each object.

    And NO, there is no other way. The COG RAM is only readable by the COG itself.
  • ProcessingData...ProcessingData... Posts: 208
    edited 2009-04-17 23:18
    Shoot, I was hoping for a better answer. Anyway, I wanted it so i could display pin directions, and if they were high or low as a sort of pin-debugger so you could use two cogs (one for video, other for pins and user interface) to view the pin states as your program runs. Oh well, I guess I'll have to have the user enter some lines of code into their program...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Basic Stamp,···· Propeller,·· · SX,·· FUN!


    START:·
    >Proccessing Data. . . .··
    >Task Complete. . .·.
    >Saving Data. . . .
    >Entering SLEEP Mode. . . .
    >Signing OFF


    ·
  • jazzedjazzed Posts: 11,803
    edited 2009-04-17 23:22
    Sorry but you will have to add code somewhere. Output the value of bits that you care about to some spare pins with one cog and read the pin states using the other cog. Only up to 28 bits are usable. Some think Linus is doing that with his demo.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-04-18 02:15
    As Steve said, you could use a pin(s) to repesent whether they are outputs. Remember they are or'ed together, so you can place a 1 in a pin if the cog is using the pin.

    Also, you can wire or yourself by using a pullup (10K) and just driving the dir register on/off with the outa =1.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
    · Search the Propeller forums (via Google)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-04-18 02:59
    One thing you can do, altough it isn't exactly non-disruptive and requires series resistors on all your pins: wait for a pin to become high, then try driving it low. If the pin is an output, that will fail; if an input, it will succeed.

    It's a stupid idea, really, but provides the desired info, assuming each pin eventually sees a "high".

    -Phil
Sign In or Register to comment.