Shop OBEX P1 Docs P2 Docs Learn Events
Why won't this work? — Parallax Forums

Why won't this work?

RichardFRichardF Posts: 168
edited 2007-06-11 10:00 in Propeller 1
I simply want to capture the cogid when I start a cog and display it on the Lcd. Code works fine (LED flashes) until I assign the result of cognew to cog, then cog doesn't run (no flashing LED), and there is no fall through to updateLcd. Cog "hangs"??

CON
_clkmode····· = XTAL1 + pll16x
_xinfreq····· = 5_000_000
LCD_PIN·· = 0··························· ' for Parallax 4x20 serial LCD on A0
LCD_BAUD· = 19_200
LCD_LINES = 4
VAR
long stack1[noparse][[/noparse]5]
byte cog

OBJ
·· lcd : "debug_lcd"

PUB start
'start LCD
if lcd.start(LCD_PIN, LCD_BAUD, LCD_LINES)···········
··· lcd.cursor(0)······································ ' cursor off
··· lcd.backLight(true)·······························' backlight on (if available)
··· lcd.cls············································· · ' clear the lcd
··· lcd.gotoxy(0,0)
··· lcd.str(string("Cog: "))
··· lcd.decf(0, 8)

cog := cognew(flashLED, @stack1)····························· PROBLEM HERE

updateLcd(cog, 0)

PRI flashLED
dira[noparse][[/noparse]15]~~
repeat
· !outa[noparse][[/noparse]15]
· waitcnt(clkfreq/2 + cnt)

PRI updateLcd(value, LcdLine)
· case LcdLine
··· 0:
····· lcd.gotoxy(12, 0)
····· lcd.decf(value, 8)····················· ' print right-justified decimal value
··· 1:
····· lcd.gotoxy(12,1)
····· lcd.decf(value, 8)
··· 2:
····· lcd.gotoxy(12,2)
····· lcd.decf(value, 8)·
··· 3:
····· lcd.gotoxy(12,1)
····· lcd.decf(value, 8)···

Thanks,
Richard

Comments

  • RinksCustomsRinksCustoms Posts: 531
    edited 2007-06-11 00:11
    have you tried a "pause" right after the cognew? it may help stability, everything else looks ok.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Definetly a E3 (Electronics Engineer Extrodinare!)
    "I laugh in the face of imposible,... not because i know it all, ... but because I don't know well enough!"
  • RichardFRichardF Posts: 168
    edited 2007-06-11 00:24
    It's not the "updateLCD" that is the problem, the cog won't run when I assign the result of

    cognew(flashLED,@stack1) to cog.

    Remove "cog :=" and flashLED runs fine. Of course the cog number update in the LCD doesn't update. I just want to display the cog number on the LCD when I start a new cog. Should be real easy to do, but it isn't coming out that way.

    Thanks,

    Richard
  • CardboardGuruCardboardGuru Posts: 443
    edited 2007-06-11 07:57
    Increase the size of the stack?
  • RichardFRichardF Posts: 168
    edited 2007-06-11 10:00
    Yes, that worked. Thanks.
Sign In or Register to comment.