assignment problem - am I stroked with blindness?
virtuPIC
Posts: 193
I want to measure period times of an input pin signal. To test the code I want to run debug output on the same cog. To reduce the data load to a reasonable amount I try to run the output only ten times per second. The code fails: Debug output is sent every loop cycle. Find the stripped down code below. It should print the values of cnt and variables cntdisplay and cnt0 ten times per second. I see many more writings - but cntdisplay always has value 0. That am I missing here?
Any help appreciated!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys
Post Edited (virtuPIC) : 5/15/2009 11:58:15 AM GMT
Any help appreciated!
CON _clkmode = xtal1+pll16x _clkfreq = 80_000_000 OBJ pc : "PC_Text" PUB theremin | cnt0, cntdisplay pc.start(pc#TXPIN) cntdisplay := cnt repeat cnt0 := cnt 'delay will go here cnt0 := cnt - cnt0 if cnt - cntdisplay >= clkfreq / 10 pc.dec(cnt) pc.str(string(" ")) pc.dec(cntdisplay) pc.str(string(" ")) cntdisplay := cnt pc.dec(cnt0) pc.str(string($0d))
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys
Post Edited (virtuPIC) : 5/15/2009 11:58:15 AM GMT
Comments
I would probably rearrange some of this to be easier to read like this:
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
Post Edited (James Long) : 5/15/2009 10:03:30 AM GMT
if cnt - cntdisplay >= clkfreq / 10
underline?
In my programms the headline looks like this:
CON
_clkmode = xtal1 + pll16x ' sysclk setup
_xinfreq = 5_000_000
OneSecond = 80_000_000 ' number of sysclk cycles during one second
Ha, didn't catch that.
James L
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services
What do you mean with 'underline'? Writing '_clkfreq' and reading 'clkfreq' is perfectly correct according to the propeller manual. The other way round is wrong.
I just looked up '_clkfreq' vs. '_xinfreq' in the manual. Both are possible. You can read the number of sysclk cycles per second from 'clkfreq' - no matter which of the two you define.
I tried your proposal. Doesn't help. Anyway, I hadn't expect it would since the problem doesn't seem to be in the counter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys
">=" does not mean "less than or equal"; it is an assignment operator. "a >= b" is the same as "a := a > b". Use "=>" instead.
AAAaaarrrggghhh!!!!!! I was stroked with blindness. I know why I prefer to program in PASM instead of SPIN.
This little correction helped a lot.
Thank you very much!!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Airspace V - international hangar flying!
www.airspace-v.com/ggadgets for tools & toys