clkfreq not the same inside cognew?
bunni
Posts: 38
I've spent a good chunk of time trying to track this down with no avail, this is my first time even trying spin. Basically, I am trying to run a method in a cog, when I do the clkfreq variable seems to be screwing everything up. Basically, this works:
While this doesnt:
The former code toggles the LED at .5hz, the latter is about .01hz blink.
Can anyone explain to me what I am missing here? According to the manual clkfreq is a global read only variable, while I believe the cog has to wait for the hub to access this variable, it should in no way impact the waitcnt method.
CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 PUB init cognew(ledon(clkfreq), stack) PUB ledon(rate) dira[23] := %1 repeat !outa[23] waitcnt(rate + cnt)
While this doesnt:
CON _clkmode = xtal1 + pll16x 'Standard clock mode * crystal frequency = 80 MHz _xinfreq = 5_000_000 PUB init cognew(ledon, stack) PUB ledon dira[23] := %1 repeat !outa[23] waitcnt(clkfreq + cnt)
The former code toggles the LED at .5hz, the latter is about .01hz blink.
Can anyone explain to me what I am missing here? According to the manual clkfreq is a global read only variable, while I believe the cog has to wait for the hub to access this variable, it should in no way impact the waitcnt method.
Comments
Did you RTM (Propeller Manual V1.2, p79)?
First of all, yes, I do have a stack declaration, a stupidly huge 500 longs:
I just accidentally chopped it out when formatting my code here for paste.
Second, ahh Smile again. Thats what I get for trying to learn a new language after 8pm. Everything magically works now, who would have thought?! Thanks for the help guys. Can we please delete this thread to hide my blatant stupidity?
Delete it??? Where do you think we get our free entertainment from? 500 longs for a stack, who'd have thunk it!
BTW, after 8pm is always a good time to learn a new language, I don't warm up until around 11pm myself.
How You think Others can learn from Yours mistake's if You delete this thread?
Can you post your working code, so we can learn from your result? The kids will likely encounter this same issue in an upcoming project.
I was just joking
As requested: