Cog not starting
SolderHead
Posts: 7
I'm trying to generate PWM output for a project, the cognew command I use is not returning -1, but the code in the function is not running. If I run the function inline it works 100%, but I need it running on a seperate cog. Any Ideas? It's just a standard SPIN function, I'm using this to start the cog
Cog := cognew(mainloop, @Stack)
Maybe the Stack is not big enough? long Stack[120] ...I'm relatively new to this, help would be great. Thanks.
Cog := cognew(mainloop, @Stack)
Maybe the Stack is not big enough? long Stack[120] ...I'm relatively new to this, help would be great. Thanks.
Comments
Yes, any kind of problems can occur if your stack is smaller than the needed stack. So it's possible that this is the cause of your problem, but without code nobody can tell you for sure.
pub mainloop(dummy) | framets, pin, ts
repeat
framets := cnt+(clkfreq / _1uS * 20000)
repeat pin from 0 to 7
ts := cnt
outa[OutputPins[pin]] := 1
waitcnt(ts+ServoData[pin])
outa[OutputPins[pin]] := 0
waitcnt(framets)
Start is as such...
PUB Start | pin
repeat pin from 0 to 7
Set(pin, 1000)
Cog := cognew(mainloop(0), @Stack)
'mainloop
if I un-comment mainloop it functions 100% correctly. But not when starting a new cog up.
Brilliant, Thanks so much. That helped. Happy days...