Shop OBEX P1 Docs P2 Docs Learn Events
Propeller chip organization - NewB question — Parallax Forums

Propeller chip organization - NewB question

roedjroedj Posts: 6
edited 2011-09-24 04:02 in Propeller 1
All,

I've read the manual several times and just when I think 'I got it', I don't 'got it'.

The way I understand it now is that I can have nine executable programs running at the same time - one in each cog and one in the Main Memory. I would be writing these programs in assembler and not Spin.

Is this correct?

I understand (?) that the cogs can only have access to Main Memory through the Hub but basically if I have, say four cogs, each watching a different I/O pin set to Input, I could, in effect, have four interrupts running at the same time, although they would only have access to the Main Memory when 'it's their turn'.

Is this correct?

Thanks for your help,

Dan

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-09-23 08:51
    Welcome to the forum roedj...

    The Propeller has 8 COGs, so you can have 8 parallel process runnning at one time.

    Yes, all COGs have access to HUB RAM in a round robin fashion and each COG has access to I/O.

    Please see the "Propeller Education Kit (pdf)". The PDF has a lot of great information and examples. Propeller Tool -> Help -> Propeller Education Kit (pdf).
  • blittledblittled Posts: 681
    edited 2011-09-23 08:58
    When the Propeller starts up it uses one cog to load in the SPIN interpreter to run the program in HUB memory. This leaves you 7 cogs to run other processes. The cog with the SPIN interpreter can be stopped so you can run an eighth process.
  • jazzedjazzed Posts: 11,803
    edited 2011-09-23 09:02
    You can have 8 total Spin "programs" running in a Propeller at once. The main program runs at boot-up and it can start other Spin "programs" in the 7 other COGs (or Spin/PASM based objects). The 7 Spin other "programs" are really part of the main program, but have separate methods (functions defined with PRI or PUB) that can do other things and have their own "threads" of execution. And yes, the main program can replace itself as blittled mentioned if you're careful. You don't need to learn PASM to enjoy Propeller's multi-core abilities.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-09-23 14:30
    roedj: Welcome to this fabulous forum and the propeller chip.

    As you can see, the others have answered you initial questions. Not much more to add except that there are no interrupts in the prop. If you are already used to interrupts, then initially it is a little harder to grasp but once you get used to a different way of thinking you'll be glad there are no interrupts. If you are not used to interrupts, then it is way easy without them.

    Just to clarify a little further. Spin is actually a pasm program that fills cog ram and executes from there. It is really an interpreter and loads bytes from hub to execute the functions in cog. You do not need to worry about hub contention provided you understand each cog gets its own time slot to access the hub every 16 clocks in a round robbin method. So, one cog might write a byte/word/long to hub and another cog will not see that hub data (read it and see the change) until its next timeslot. All cogs can access all 32 I/O pins. If more than one cog writes to the same I/O pin they are "or"ed together internally so any one high will result in a high out and there is no contention problem - its a legal operation and can be useful.

    The other thing is that there are a lot of objects in obex that include pasm to make various intelligent peripherals for the prop including serial objects, video drivers (TV and VGA), keyboard (PS2), etc. These may be used without understanding pasm.

    Pasm is actually quite easy compared to other assembler code used in other processors because of the regular instruction set and small number of instructions. There is also no registers/accumulators as such, just the whole cog memory. This is because each instruction (most) access two locations for the data and stores the result in the second.

    If there is something you dont understand, just ask. Please ensure your title reflects the main part of your question. If you post code please use the advanced section and place it in code tags to preserve the indentation, or post the whole zip file (ProtpTool will zip it all up for you).
  • TubularTubular Posts: 4,726
    edited 2011-09-23 14:57
    Hi Roedj, welcome to the Propeller Forum

    I think from a previous post you were looking to monitor 8 pulse width (servo) channels, is that still the plan?

    The good news is each cog has 2 counters, which could help count the width of the pulses for you, only taking 4 cogs total. There would be ways of reducing this further if you had to.
  • roedjroedj Posts: 6
    edited 2011-09-23 22:50
    Tubular wrote: »
    Hi Roedj, welcome to the Propeller Forum

    I think from a previous post you were looking to monitor 8 pulse width (servo) channels, is that still the plan?

    The good news is each cog has 2 counters, which could help count the width of the pulses for you, only taking 4 cogs total. There would be ways of reducing this further if you had to.

    Yes. That is still the plan. I came to the same conclusion about two days ago. I figure to use both counters in each of four cogs to time two of the eight PWM channels and still have four cogs left over to watch the other analog and digital sensors, do some calculating and send out an ASCII string to the Propeller Servo Control Board.

    I'll post some first-attempt assembler code for criticism.

    Thanks to all for your replies,

    Dan
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-09-24 04:02
    IIRC there is a servo receiver object in the obex that will receive and decode up to 8 servo style inputs from an RC receiver. That may help.
Sign In or Register to comment.