View Full Version : Cogs and things

Jon M
09-11-2007, 12:10 AM
Hi Guys,

OK, new to the prop and struggling!!· I have a few questions for you clever people out there...

1) is there a debug I can use to see the value of variables etc like we have in the stamp software?
2) when using several cogs do you have to declare the·direction of the I/O's·for each cog or can·I set the I/O directions globally.
3)·if I create an object·containing my 'library routines' then use the OBJ command to place them in my top level program, how do I move data between them. also how do I then use one of those routines in it's own cog.
4) How do you call routines? I can't find anything that resembles gosub or goto

I know these are probably really silly questions, and yes I've read the manual and the education pages and still struggling.· The ed pages in some respects are too simple, turning on LEDS at different speeds etc, but don't show how it all comes together in a real world program where you are monitoring several I/Ps, calculating values of variables etc.




09-11-2007, 12:26 AM
Jon , try looking thru the stickies on the top of this forum , there blue colored and have alot of info.

········ Dave


Fix it if ain't broke·
D Rat

Dave Ratcliff· N6YEE

09-11-2007, 01:26 AM
1. Not really - you kind of need to grow your own.

2. I learned the·answer to this question the hard way.· The direction registers for the I/O pins are distinct for each cog.· And the actual effect at the I/O pin is the logical OR of all of the 8 direction registers.· So, each cog must set a pin to output if it wants to use it that way.· And if any one or more cogs sets a pin to output, it will be output, regardless of anyone who has it set to input.

This works the same way for the value of the output at the output pin.· If any of the cogs with that pin set to output set the output to high, then it will be high, no matter how many try to set it low.

3. There are many ways to pass data to and from objects or methods.· They can reference common areas of RAM or arguments can be passed when the method is called.· Kind of hard to explain here.· See the manual and look over lots of example code posted here and in the Object Library.

4. You invoke a "subroutine" or method as they are called in Spin by just stating it's name.· There is no need for the word Gosub.· And with Spin being structured, there is no Goto needed.

Stan Dobrowski

09-11-2007, 01:36 AM
I should like to add:
(1) Search for
- PropTerminal
- Viewport
- SerialMirror

(2) Study the basic architecture diagram of the Propeller: You will see ALL relevant components, and ALL relevant ANDs and ORs wrt I/O

(3) When using SPIN you do not have to care much about the COG...
But there is an "information hiding" concept between objects... Direct use of other object's variables is not supported by SPIN; you have to use pointers...
This has nothing to do with "COGs" but had been a "design decision" for SPIN, most likely to simplify the compiler..

(4) Also read chapter 3 of the Manual http://forums.parallax.com/images/smilies/smile.gif

Jon M
09-11-2007, 04:19 PM
thanks guys, very helpful. no doubt i'll be back soon with many more questions