Shop OBEX P1 Docs P2 Docs Learn Events
Stumped: No luck watching a cogs output pin. — Parallax Forums

Stumped: No luck watching a cogs output pin.

PaulPaul Posts: 263
edited 2007-03-08 20:47 in Propeller 1
I'm trying to·watch the state of a pin that a cog is outputting with a 60 hz signal.· I can't figure out how to get the signal to show up on pin A6. Pin A5 works fine. Knowing that all cogs "share" I/O pins I thought this would be fairly easy. What piece of the puzzle am I missing?
Thanks,
--Paul
{{TESTS reading outa[noparse][[/noparse]21] }}

con
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
  
VAR    ' Global Variables
  long  stack[noparse][[/noparse]20]
  byte  pin
  
PUB Start
  dira[noparse][[/noparse]6]~~
  cognew (square( 21 ),@stack)       
  repeat
    outa[noparse][[/noparse]6] := outa[noparse][[/noparse]21]    '<<< Doesn't work!
 
PUB square(pn)                              
  dira[noparse][[/noparse]pn]~~
  dira[noparse][[/noparse]5]~~
  repeat
    !outa[noparse][[/noparse]pn] 
    waitcnt(clkfreq/60 + cnt)
    outa[noparse][[/noparse]5] := outa[noparse][[/noparse]pn]    '<<< works 'inside' cog.


EDIT: Ok this is 30 Hz ...but still the same problem

Post Edited (Paul) : 3/8/2007 7:43:41 PM GMT

Comments

  • Christof Eb.Christof Eb. Posts: 1,161
    edited 2007-03-08 20:24
    Hi Paul

    I am not completely sure, but could you try
    outa[noparse][[/noparse]6] := ina[noparse][[/noparse]21] ?

    I assume, it does not work, because you try to read the output register of a different cog.

    Christof
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-08 20:30
    Each cog has its own output register (OUTA). You can read the actual state of the pin with INA. Christof Eb. is right. You're reading the main cog's OUTA[noparse][[/noparse]21] which is not the same as the one in the cog running square(21).
  • PaulPaul Posts: 263
    edited 2007-03-08 20:41
    Hi Christof,

    yep, that worked! I'm not sure why either. I must have read that part of the manual backwards. I thought the output register outa, held the status. I guess thats only internal to the cog.

    It's interesting that: outa5 and outa[noparse][[/noparse]6] are now 180 out of phase.

    Back to the books for me!
    Thanks very much.
    --Paul

    Post Edited (Paul) : 3/8/2007 8:50:22 PM GMT

  • PaulPaul Posts: 263
    edited 2007-03-08 20:47
    Thanks Mike
Sign In or Register to comment.