Simple Code not working?
Xetar
Posts: 10
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)
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
Thanks that did the trick. And I'll try the archive thing next time.