Shop OBEX P1 Docs P2 Docs Learn Events
Simple Code not working? — Parallax Forums

Simple Code not working?

XetarXetar Posts: 10
edited 2010-10-26 14:42 in Propeller 1
In the following code, the variable: "long[pValue]" never changes from zero. I'm assigning it a value from my LTC1298 with this line "long[pValue] := gblAD1.GetADC(0)"

I have verified that the cog is working, if you look you will see a line commented out that just increments the value. This works an the value goes up accordingly. However when I replace it with the call to my A2D chip, all i get is 0.

If I move the A2D chip code to my primary cog, I see the value just fine. Any idea what i'm doing wrong here?



CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

VAR
LONG gblA2D_Cog
LONG SqStack[20]

obj
gblAD1 : "CD_LTC1298" 'A2D driver


PUB StartProcess(pValue)

gblA2D_Cog := cognew(Process(pValue), @SqStack)


PUB Process(pValue)

' Initialize the A2D driver
gblAD1.start(0)


repeat
' Get the A2D reading
' long[pValue]++
long[pValue] := gblAD1.GetADC(0)

Waitcnt((clkfreq / 10) + cnt)


PUB StopProcess

if gblA2D_Cog
cogstop(gblA2D_Cog~ - 1)

Comments

  • ratronicratronic Posts: 1,451
    edited 2010-10-26 14:06
    Xetar - I tried this and it seems you need to increase your SqStack amount a bit then it works. You can archive your whole code to post here in the file menu in the propeller tool.
  • train nuttrain nut Posts: 70
    edited 2010-10-26 14:18
    I may be wrong but I believe that "long" is a reserved word in spin and cannot be used as a variable.
  • XetarXetar Posts: 10
    edited 2010-10-26 14:42
    ratronic wrote: »
    Xetar - I tried this and it seems you need to increase your SqStack amount a bit then it works. You can archive your whole code to post here in the file menu in the propeller tool.

    Thanks that did the trick. And I'll try the archive thing next time.
Sign In or Register to comment.