MinimumWage
01-26-2008, 03:18 PM
Hi all,
I'm hoping someone can help me with this. I am trying to run the program below but am getting unusual results with the waitcnt statement in the BeatCount subroutine. I stripped it down from another program for troubleshooting - all it does is pass a shared value between cogs. No matter what value I use in that waitcnt statement the cog gets stuck for almost a minute before updating the beatavg value. I'm sure that indicates that the cog is waiting for the system counter to roll over, but I don't understand why. I've never had a problem like this with a simple waitcnt statement and feel like I must be missing something obvious...
CON
_clkmode = xtal1 + pll8x 'set for SPINSTAMP!!
_xinfreq = 10_000_000
b_out1 = 1
VAR
long stack1[50]
long stack2[50]
long beatavg
PUB Main
cognew(BeatCount, @stack1)
cognew(FlashLED, @stack2)
PUB BeatCount
waitcnt(clkfreq + cnt)
beatavg := clkfreq/10
PUB FlashLED
dira[b_out1]~~
repeat while true
outa[b_out1] := !outa[b_out1]
waitcnt(beatavg + cnt)
Basically, when I run this code as-is the LED flash frequency doesn't get set to 1/10 sec for almost a minute. If I comment out the first waitcnt statement, it updates instantly.
Post Edited (MinimumWage) : 1/26/2008 8:23:05 AM GMT
I'm hoping someone can help me with this. I am trying to run the program below but am getting unusual results with the waitcnt statement in the BeatCount subroutine. I stripped it down from another program for troubleshooting - all it does is pass a shared value between cogs. No matter what value I use in that waitcnt statement the cog gets stuck for almost a minute before updating the beatavg value. I'm sure that indicates that the cog is waiting for the system counter to roll over, but I don't understand why. I've never had a problem like this with a simple waitcnt statement and feel like I must be missing something obvious...
CON
_clkmode = xtal1 + pll8x 'set for SPINSTAMP!!
_xinfreq = 10_000_000
b_out1 = 1
VAR
long stack1[50]
long stack2[50]
long beatavg
PUB Main
cognew(BeatCount, @stack1)
cognew(FlashLED, @stack2)
PUB BeatCount
waitcnt(clkfreq + cnt)
beatavg := clkfreq/10
PUB FlashLED
dira[b_out1]~~
repeat while true
outa[b_out1] := !outa[b_out1]
waitcnt(beatavg + cnt)
Basically, when I run this code as-is the LED flash frequency doesn't get set to 1/10 sec for almost a minute. If I comment out the first waitcnt statement, it updates instantly.
Post Edited (MinimumWage) : 1/26/2008 8:23:05 AM GMT