Compiler / P2 oddity
kbash
Posts: 117
in Propeller 2
I posted the following in the NEWBIE discussion but didn't get a response. I think this is the sort of oddity that those of us who purchased the eval board are looking for, I wanted to verify whether it is something I just don't know about the P2 or if it is something odd in the behavior of either the compiler or the P2 itself:
I'm trying out my first code changes with PNUT on my P2 eval board.
I started off with Chips original blink program. Instead of initializing a group of cogs with a loop ( which works fine) I changed the code to initialize a single cog with the blink function, then initialize a second cog with another blink routine. These functions work fine UNLESS the first cog initialized is either cog 0 or cog 2. In this case, only the first cog seems to be functioning.
( Change cognum1 to 0 or 2 to verify in the attached code )
Is this something I don't understand about the P2, the Eval board or something odd about the compiler itself?
Any ideas?
I'm trying out my first code changes with PNUT on my P2 eval board.
I started off with Chips original blink program. Instead of initializing a group of cogs with a loop ( which works fine) I changed the code to initialize a single cog with the blink function, then initialize a second cog with another blink routine. These functions work fine UNLESS the first cog initialized is either cog 0 or cog 2. In this case, only the first cog seems to be functioning.
( Change cognum1 to 0 or 2 to verify in the attached code )
Is this something I don't understand about the P2, the Eval board or something odd about the compiler itself?
Any ideas?
Comments
Otherwise it keeps executing stuff you probably don't want it to...
I modified your example to use P56 for blink and P57 for blink2 because adding 56 to the cogid can not work with cog 7 since pin 63 is used for serial.
I also put your starting cog 0 into a loop at the end so that it does not run into your data
Enjoy
Mike
I already found out that reversing the order of the cog startups seems to work fine. There's not a problem with GETTING the blink program to work with both the 0 and cogs 1-7.
I also understand now why initializing cog 0 first would clobber the code that was currently running on cog 0 and fail to initialize more code.
What I DON'T understand is why initializing cog 2 first would clobber the code the same as initializing cog 0 first. I can't think of anything that would be running on cog 2 that would lock up the rest of the sequence.
I'm fine with "leaving it alone " since I can get around it... but if it is an unknown bug in either the compiler or the silicone... it needs to be understood.
It is more likely a problem with my understanding of the way things work, like starting cog 0 first. I get that one now. ... but what's the problem with starting cog 2 first ?
Mike
What I DON'T understand is why initializing cog 2 first would do the same thing. The initialize code is running on cog 0. It SHOULD initialize cog 2 to blink then go on to initialize the other cog whatever it's number is. It operates as if initializing cog 2 is clobbering the setup code exactly like it does with setting up cog 0 first. All other combinations I've tried seem to work fine.
Mike
That's my program exactly as I'm running it. On my P2-EV board, compiled as is, only LED 58 blinks
Does it work the same way on another EV board or is it only mine?
By the way... what do you fly?
look at my listing I provided as example 9 posts up.
You are running into your data.
Your first cog (cog 0) does the two coginits and then runs into your definition of cognum1 und tries to execute it.
After your coginits you have to stop your cog from running into your data.
would do it
Mike
That gets rid of the problem when cog 2 is initialized first. I don't quite understand why all the other combinations work and that one doesn't but I've got a very long way to go to fully understand the P2 so we're good. Thanks!
Yes ersmith... all led's blink fine. ( and in any other combination) I agree with Marsman if that's whats going on... and I suspect it is just my lack of understanding, not a P2 problem. However... it does strike me as a bit strange that Mike (msrobots) said his board worked fine with the code that mine hangs up on. I would expect all the P2 chips and boards to be the same.
I'm pretty sure he fixed your code so it wouldn't run into the data in his first post. So what worked was the fixed code.
Usually,. yes, but the RAM contents will not be the same across all boards. That depends on what was loaded in the past, and power up is random.
which sends the executing cog into nirwana land somewhere since it rotates memory position 0 right by two bits and then does a ret without a call first.
I think your misunderstanding is the use of coginit. It is not a assembler directive meant that you want to start one cog for blink1 and one cog to start blink2.
You are already running on cog0 and these are assembly instructions carried out by cog0.
And cog0 now starts the other cogs and after that it is running into long 2 which is the instruction above.
Mike
Ken