cognew command freezes propeller chip
tony_89
Posts: 14
I've tried many different approaches to solving this problem. The cognew command on line 39 should send the lcdbl pub into a new cog. The lcdbl pub is designed to turn on the blacklight when any of the input buttons are pressed. The program should launch this into a new cog and continue on to the main pub. If anyone can solve this problem please help. I've been trying to fix it for about 6 hours now... I'm a newbie to propeller. The attachment manager is not working so i had to copy paste. sorry for the inconvenience!!
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
LCD_PIN = 14
LCD_BAUD = 19_200
LCD_LINES = 2
var
byte set_temp, set_freq, set_amps, temp,temp_max ,temp_min, value
long stack[noparse][[/noparse]1000]
OBJ
lcd: "debug_lcd"
pub ini
if lcd.init(LCD_PIN, LCD_BAUD, LCD_LINES) ' start lcd
lcd.cursor(0) ' cursor off
lcd.backLight(true) ' backlight on (if available)
lcd.cls ' clear the lcd
lcd.str(string("Hydrogen", 13 ,"thermostat"))
waitcnt(clkfreq *1 + cnt)
lcd.cls
lcd.str(string(129,"designed by:", 13," Anthony Ford"))
waitcnt(clkfreq *1 + cnt)
lcd.cls
lcd.str(string(" Initialization", 13))
repeat 16
waitcnt(clkfreq/10 +cnt)
lcd.str(string("-"))
lcd.str(string(152, "complete"))
waitcnt(clkfreq * 1 +cnt)
lcd.cls
cognew ((lcdbl), @ stack)
main
dira [noparse][[/noparse]0..3]~
dira [noparse][[/noparse]4..6]~~
pub main
temp:= 75
if set_temp == 0
set_temp := 50
lcd.cls
lcd.str(string(137,"set:",156,"temp:"))
repeat
if ina[noparse][[/noparse]0]==0
waitcnt(clkfreq/2 + cnt)
set_temp ++
set_temp <#= temp_max
if ina==0
waitcnt(clkfreq/2 + cnt)
set_temp --
set_temp #>= temp_min
if ina ==0
menu
lcd.str(string(142))
lcd.dec(set_temp)
lcd.str(string(162))
lcd.dec(temp)
pub menu
lcd.cls
lcd.str(string(134,"menu"))
waitcnt(clkfreq*1 + cnt)
lcd.str(string(132,"set amps"))
waitcnt(clkfreq/2 + cnt)
repeat until ina ==0
if ina ==0
lcd.cls
lcd.str(string("set amps:"))
waitcnt(clkfreq*1 +cnt)
menu_set(set_amps,1,50)
set_amps := value
main
lcd.cls
lcd.str(string(134,"freq"))
waitcnt(clkfreq*1 + cnt)
repeat until ina ==0
if ina ==0
lcd.cls
lcd.str(string("set freq:"))
waitcnt(clkfreq*1 +cnt)
menu_set(set_freq,1,125)
set_freq := value
main
lcd.cls
lcd.str(string(129,"temp max"))
waitcnt(clkfreq*1 + cnt)
repeat until ina ==0
if ina ==0
lcd.cls
lcd.str(string("set maxtemp:"))
waitcnt(clkfreq*1 +cnt)
menu_set(temp_max,1,200)
temp_max := value
main
lcd.cls
lcd.str(string(129,"temp min"))
waitcnt(clkfreq*1 + cnt)
repeat until ina ==0
if ina ==0
lcd.cls
lcd.str(string("set min:"))
waitcnt(clkfreq*1 +cnt)
menu_set(temp_min,1,200)
temp_min := value
main
waitcnt(clkfreq*1 +cnt)
main
pub menu_set(set_value,min_value,max_value)
repeat
if ina[noparse][[/noparse]0]==0
set_value ++
set_value <#= max_value
waitcnt(clkfreq/2 + cnt)
if ina==0
set_value --
set_value #>= min_value
waitcnt(clkfreq/2 + cnt)
if ina ==0
lcd.cls
lcd.str(string("changes saved",13))
waitcnt(clkfreq*1 +cnt)
value := set_value
return
if ina ==0
lcd.cls
lcd.str(string("changes aborted",13))
waitcnt(clkfreq*1 +cnt)
main
lcd.str(string(140))
lcd.dec(set_value)
pub lcdbl
repeat
if ina[noparse][[/noparse]0] ==0
outa~~
waitcnt(clkfreq * 2 + cnt)
outa~
if ina ==0
outa~~
waitcnt(clkfreq * 2 + cnt)
outa~
if ina ==0
outa~~
waitcnt(clkfreq * 2 + cnt)
outa~
if ina ==0
outa~~
waitcnt(clkfreq * 2 + cnt)
outa~
waitcnt(clkfreq *1 + cnt)
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
LCD_PIN = 14
LCD_BAUD = 19_200
LCD_LINES = 2
var
byte set_temp, set_freq, set_amps, temp,temp_max ,temp_min, value
long stack[noparse][[/noparse]1000]
OBJ
lcd: "debug_lcd"
pub ini
if lcd.init(LCD_PIN, LCD_BAUD, LCD_LINES) ' start lcd
lcd.cursor(0) ' cursor off
lcd.backLight(true) ' backlight on (if available)
lcd.cls ' clear the lcd
lcd.str(string("Hydrogen", 13 ,"thermostat"))
waitcnt(clkfreq *1 + cnt)
lcd.cls
lcd.str(string(129,"designed by:", 13," Anthony Ford"))
waitcnt(clkfreq *1 + cnt)
lcd.cls
lcd.str(string(" Initialization", 13))
repeat 16
waitcnt(clkfreq/10 +cnt)
lcd.str(string("-"))
lcd.str(string(152, "complete"))
waitcnt(clkfreq * 1 +cnt)
lcd.cls
cognew ((lcdbl), @ stack)
main
dira [noparse][[/noparse]0..3]~
dira [noparse][[/noparse]4..6]~~
pub main
temp:= 75
if set_temp == 0
set_temp := 50
lcd.cls
lcd.str(string(137,"set:",156,"temp:"))
repeat
if ina[noparse][[/noparse]0]==0
waitcnt(clkfreq/2 + cnt)
set_temp ++
set_temp <#= temp_max
if ina==0
waitcnt(clkfreq/2 + cnt)
set_temp --
set_temp #>= temp_min
if ina ==0
menu
lcd.str(string(142))
lcd.dec(set_temp)
lcd.str(string(162))
lcd.dec(temp)
pub menu
lcd.cls
lcd.str(string(134,"menu"))
waitcnt(clkfreq*1 + cnt)
lcd.str(string(132,"set amps"))
waitcnt(clkfreq/2 + cnt)
repeat until ina ==0
if ina ==0
lcd.cls
lcd.str(string("set amps:"))
waitcnt(clkfreq*1 +cnt)
menu_set(set_amps,1,50)
set_amps := value
main
lcd.cls
lcd.str(string(134,"freq"))
waitcnt(clkfreq*1 + cnt)
repeat until ina ==0
if ina ==0
lcd.cls
lcd.str(string("set freq:"))
waitcnt(clkfreq*1 +cnt)
menu_set(set_freq,1,125)
set_freq := value
main
lcd.cls
lcd.str(string(129,"temp max"))
waitcnt(clkfreq*1 + cnt)
repeat until ina ==0
if ina ==0
lcd.cls
lcd.str(string("set maxtemp:"))
waitcnt(clkfreq*1 +cnt)
menu_set(temp_max,1,200)
temp_max := value
main
lcd.cls
lcd.str(string(129,"temp min"))
waitcnt(clkfreq*1 + cnt)
repeat until ina ==0
if ina ==0
lcd.cls
lcd.str(string("set min:"))
waitcnt(clkfreq*1 +cnt)
menu_set(temp_min,1,200)
temp_min := value
main
waitcnt(clkfreq*1 +cnt)
main
pub menu_set(set_value,min_value,max_value)
repeat
if ina[noparse][[/noparse]0]==0
set_value ++
set_value <#= max_value
waitcnt(clkfreq/2 + cnt)
if ina==0
set_value --
set_value #>= min_value
waitcnt(clkfreq/2 + cnt)
if ina ==0
lcd.cls
lcd.str(string("changes saved",13))
waitcnt(clkfreq*1 +cnt)
value := set_value
return
if ina ==0
lcd.cls
lcd.str(string("changes aborted",13))
waitcnt(clkfreq*1 +cnt)
main
lcd.str(string(140))
lcd.dec(set_value)
pub lcdbl
repeat
if ina[noparse][[/noparse]0] ==0
outa~~
waitcnt(clkfreq * 2 + cnt)
outa~
if ina ==0
outa~~
waitcnt(clkfreq * 2 + cnt)
outa~
if ina ==0
outa~~
waitcnt(clkfreq * 2 + cnt)
outa~
if ina ==0
outa~~
waitcnt(clkfreq * 2 + cnt)
outa~
waitcnt(clkfreq *1 + cnt)
Comments
Please copy and paste your code here: www.phipi.com/format, click Format, and repost the result. This will preserve your indents and subscripting so the program is readable. As it stands, it is not.
Thanks,
-Phil
Are you sure it makes it to the cognew command? Is it possible its locking up before that?
The website I linked to will do all your formatting for you, including adding the [noparse][[/noparse]code] tags and protecting your subscripts (which the [noparse][[/noparse]code] tags alone will not do). It will work with any browser. That's why I suggested it.
-Phil
There is an attachment manager in the posting editor...see button at the
bottom of the editor screen.
INSTEAD of posting a LONG LONG unformatted code that is a load of
USELESS text
WHY NOT ATTACH your .Spin file......only post code fragments that you need
to talk about· in the posting. BUT.... use the #·button from the Speed Buttons
at the top of posting editor.
Check out your postings editor....it has tools you can use to make your posting more readable.
Also at the bottom of the edit area there is a button labeled "Attachment Manager"
USE this to attach your Spin files.....we can read them a lot better using our
Propeller Tool than the unformatted LENGTHY LENGTHY waste of space.
Also this helps people read your code and test it and that way can help you better
with your problem.
The posting Editor is not very different from most editors you have used. TAKE A MINUTE
to LOOK at it and figure out how to use it.
ALSO ....if you need to practice use the Test Forum·on this site.
·
Regards
Samuel
·
2) The source code you've posted ("temp buttons.spin") doesn't have a COGNEW anywhere in it. From the original cut and paste, you had "cognew ((lcdbl), @ stack)". The "(lcdbl)" is incorrect. Please read the Propeller Manual section on the COGNEW statement. "lcdbl" without the parentheses would be correct.
Thanks. Much better.
Each cog has its own dira. Setting a bit in dira in one cog does not make it an output in another. Once you've made the corrections Mike has suggested, you may want to address this issue.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 9/8/2009 4:40:55 PM GMT
4) You could use ABORT to quit everything out to a certain level. In "init", you have a call to "main". You could change this to:
and everywhere you have a call to "main" that's intended to exit back to the top of "main", you'd put ABORT. Read the Propeller Manual section on the ABORT statement.
5) What's this "INA[noparse][[/noparse] -1 ]"? There are no negative pin numbers. Spin uses just the least significant 5 bits of the pin number, so a -1 is the same as 31.
Post Edited (Mike Green) : 9/8/2009 4:44:15 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propeller Tools
Sorry for the simple questions i have only been working with propeller for 13 days but i need to complete my design asap.
Look at the "Basic_I2C_Driver" from the Object Exchange. You can use the routines in that to read and write EEPROM locations. The end of the EEPROM is usually unused (from the end of your program to the end of the EEPROM) and is not changed until you download a new program to the EEPROM. Typically you store persistent information starting at the end. If you need to store a 32-bit value, start at $7FFC and work downwards. The unused EEPROM is normally zeroed by the boot downloader.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm