Why won't this work?
RichardF
Posts: 168
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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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!"
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