Shop OBEX P1 Docs P2 Docs Learn Events
COGNEW brings things to a halt — Parallax Forums

COGNEW brings things to a halt

Hi,
I might be being thick here but please could I have some pointers (excuse the pun) to where I might be going wrong?
I have created some stackspace in the VAR section
Long stackOB[10]
and written a pub:
PUB OB | arepeat     a := a
In the main PUB I have included
r := cognew(OB, @stackOB)lcd.dec(r)
but it doesn't get past the cognew statement; comment it out and it runs perfectly (showing 0 on the LCD).
What have I done that I shouldn't, or haven't done that I should've? It's probably obvious but I have been staring at it so long I can't see the wood for the trees.
Thanks in advance,
Hugh

Comments

  • The stack size may be a little small.  Try making it 20 instead of 10.  If that doesn't work you should post all your code.
  • Thanks.
    Increasing the stack size to 35 longs didn't help. It is doing quite a few other things at the same time but disabling these made no difference - even the Cognew returning '0' would be useful.
    The archived project is attached - I can only comment "you did ask!". Its not pretty, concise or well-commented...
    It is polling a serial interface with an ELM327 chip to get values of engine data from the ECU on my car. Gathering the engine data works, gathering accelerometer data works, gathering GPS data works, writing all that data to an SD card works. Uncommenting that cognew brings it to a halt.
  • There's something else going on. In isolation, your little method launch works just fine. I tend to start with a stack of 16 and go from there as needed.
  • Looking at the code in your archive, StackOBD is declared as "byte", not "long".
  • Yes, change StackOBD to a long.  It is currently defined as a byte, and is not on a long address boundary.  It is only 35 bytes in size, which is less than 9 longs, so it may not be large enough.  Also, the stack must be on a long boundary.
  • Thanks. I'll keep playing with it. I've been to-ing-and-fro-ing between bytes and longs all day...
  • Same code (using long), different board and it works as expected.
Sign In or Register to comment.