cognew not working...new to prop
bulkhead
Posts: 405
**problem solved (I forgot each cog has its own dira, outa registers, so I had to reset my dira[noparse][[/noparse]pins]**
I have in my main method:
where stack is stack[noparse][[/noparse]60]
Here is the startMotors method:
I have an LED light up for 1 second if the startMotors method runs, but I never see the LED light. However, the loop after the "cognew" line executes fine (as indicated by LEDs). What am I doing wrong? Here is the entire code:
Post Edited (bulkhead) : 7/28/2007 3:25:01 AM GMT
I have in my main method:
cognew(startMotors(10), @stack[noparse][[/noparse]0])
where stack is stack[noparse][[/noparse]60]
Here is the startMotors method:
PUB startMotors(startPin) | T,dt,motorLeftSpeed,motorRightSpeed
I have an LED light up for 1 second if the startMotors method runs, but I never see the LED light. However, the loop after the "cognew" line executes fine (as indicated by LEDs). What am I doing wrong? Here is the entire code:
'' File: SumoBot.spin '' controls sumobot! VAR byte motorLeft 'duty cycle, -100 to 100 % byte motorRight long stack[noparse][[/noparse]60] CON _xinfreq = 5_000_000 ' 5 MHz external crystal _clkmode = xtal1 + pll16x ' 5 MHz crystal multiplied → 80 MHz PUB mainMethod motorLeft :=0 motorRight :=0 dira[noparse][[/noparse]21..23]~ 'switches dira[noparse][[/noparse]4..9]~~ 'LED's outa[noparse][[/noparse]4..9]~ 'LED's off cognew(startMotors(10), @stack[noparse][[/noparse]0]) repeat '**THIS LOOP WORKS** {{loop stuff}} ' 6 pins....en1, en2, c1,c2,d1,d2 PUB startMotors(startPin) | T,dt,motorLeftSpeed,motorRightSpeed dira[noparse][[/noparse]startPin..startPin+5]~~ 'change to output outa[noparse][[/noparse]startPin..startPin+5]~ 'motors off dT := clkfreq / 80 ' 1kHz refresh rate outa[noparse][[/noparse]7]:=1 '**NEVER GOES ON** waitcnt(cnt+80_000_000) repeat {{lots of stuff here}}
Post Edited (bulkhead) : 7/28/2007 3:25:01 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Parallax Forums - If you're ready to learn, we're ready to help.
CJ, I just tried that, and now that part works. Thanks! However, now I have another problem; the indicator LED lights when the cog first starts the method and when it enters the loop, but it never keeps repeating the loop infinitely (the indicator LED lights up once in the loop and shuts off). Here is that method:
Post Edited (bulkhead) : 7/28/2007 2:51:36 AM GMT
I suspect that one of your waitcnt calculations results in a value of cnt+0 which gives a very long pause (about a minute).