Cogs starting but not running any code
MicrocontrollerGuy
Posts: 12
I've been playing around with the Propeller for a few days, and I decided to try to convert my very basic LED display from direct drive (using 24 output pins -- ouch!) to multiplexed (using only 11 output pins). Handling the display refresh seemed like the perfect job for a cog. The problem is, I can't get cogs to work!
As far as I can tell, the cog gets created but it never actually runs any code. I played around with my primary app for quite a while trying to get it work, then I decided to write a very basic application just to test it.
Here is the code:
What I think should happen is that LED 22 comes on to confirm that CogTest is running on cog 1. LED 23 comes on for 1 second, and then blinks every 1/2 second for 10 seconds. Then cog 1 is stopped, cog 0 runs out of code and the Propeller goes to sleep (and all LEDs go off).
What really happens is that LED 22 comes on (confirming that cog 1 is the one being used), LED 23 comes on for 1 second, and then goes out. 10 seconds later, LED 22 goes off because I stopped cog 1 and cog 0 ran out of code. The Propeller is asleep.
The problem is, the code in CogTest never ran. I don't think the cog ever even really started. It gave me a cog number, but it never actually ran the code.
A couple notes:
1. I know I'm running at 5 MHz. That's what I want to do. The same problem happens at 80 MHz.
2. I know that 50 longs is way too big of a stack for this method, but I made it huge just for testing.
Can anyone help me? I'm pulling my hair out here...
As far as I can tell, the cog gets created but it never actually runs any code. I played around with my primary app for quite a while trying to get it work, then I decided to write a very basic application just to test it.
Here is the code:
CON _CLKMODE = xtal1 + pll1x _XINFREQ = 5_000_000 VAR long stack[50] PUB Main dira[22]~~ dira[23]~~ outa[23]~~ waitcnt(cnt + clkfreq) outa[23]~ if (cognew(CogTest, @stack)) == 1 outa[22]~~ waitcnt(cnt + clkfreq * 10) cogstop(1) PUB CogTest repeat outa[23]~~ waitcnt(cnt + clkfreq / 2) outa[23]~ waitcnt(cnt + clkfreq / 2)
What I think should happen is that LED 22 comes on to confirm that CogTest is running on cog 1. LED 23 comes on for 1 second, and then blinks every 1/2 second for 10 seconds. Then cog 1 is stopped, cog 0 runs out of code and the Propeller goes to sleep (and all LEDs go off).
What really happens is that LED 22 comes on (confirming that cog 1 is the one being used), LED 23 comes on for 1 second, and then goes out. 10 seconds later, LED 22 goes off because I stopped cog 1 and cog 0 ran out of code. The Propeller is asleep.
The problem is, the code in CogTest never ran. I don't think the cog ever even really started. It gave me a cog number, but it never actually ran the code.
A couple notes:
1. I know I'm running at 5 MHz. That's what I want to do. The same problem happens at 80 MHz.
2. I know that 50 longs is way too big of a stack for this method, but I made it huge just for testing.
Can anyone help me? I'm pulling my hair out here...
Comments