Shop OBEX P1 Docs P2 Docs Learn Events
Too Simple? — Parallax Forums

Too Simple?

I have successfully written code using multiple Cognew(s) before, but today I'm having difficulties.
The original program was more complicated, I was experimenting with DACs and ADCs. I got stuck when the Cognew would not launch.
So I took out all the other code until I was left with this, and it still does not launch.
VAR
long  Stack[9]

PUB Main
Dira[0]~~ 
 cognew(Pulser,@Stack)
repeat   
  waitcnt(cnt + 7000)       ' Because I was not sure what the Main method would do if not terminated.
     
PRI Pulser
repeat 
    waitcnt(cnt+1_000_000)
    !outa[0]

If I launch the Pulser method, not in a cognew, the LED does pulse.

Thanks in advance for any help. :)

Comments

  • Ok, after writing this post I thought about the DIRA. The newcog needed the DIRA in it's methode.
    I thought the DIRA[] were global.
  • Heater.Heater. Posts: 21,230
    Oh yeah. Everybody trips up on that at least once. Me, many times :)

    There are some Prop details that should be in huge bold type in the documentation. On every page!

    Alongside the # thing in PASM.


  • You should make your stack bigger. It's being overrun, but you got lucky since nothing (important) was above it. If you added more VAR variables or any sub objects, it would crash.

    If the first method a cog runs returns, it automatically does a cogstop(cogid). However, if your cog 0 returns, it will crash since the very bottom of its stack got wrecked by the Pulser cog since the Pulser cog doesn't have a big enough stack.
  • Heater. wrote: »
    Oh yeah. Everybody trips up on that at least once. Me, many times :)

    There are some Prop details that should be in huge bold type in the documentation. On every page!

    That reminds me, that I need to add a comment about this into my standard code template. Sometimes months can go by before I write another program, and that is the only way that I can avoid learning the same lesson over and over. I take comfort in knowing that I am not alone.
  • I've been thinking I could use a Propeller "cheat sheet" that would be full of these kinds of tips, a different document from the manual or the quick reference.. As I learn Spin I keep hitting all sorts of stuff like this.
  • Some of them may be in Phil's Tips n Traps
Sign In or Register to comment.