Shop OBEX P1 Docs P2 Docs Learn Events
How to run Propeller? — Parallax Forums

How to run Propeller?

AlarusAlarus Posts: 48
edited 2013-01-15 19:01 in Propeller 1
How to run Propeller?
What is the first address for the program 0x0000 - 0x000F?
How many clock cycles it takes to copy the program to the Cog?
Can the program in assembly language to be more 0x1F0?
How is the loading of programming in entered from the main memory?

Thanks in advance.
«1

Comments

  • Heater.Heater. Posts: 21,230
    edited 2013-01-13 10:22
    Welcome to the forums Alarus,

    I try not to give RTFM answers to questions here but given that it looks like your getting to know the Propeller for the first time you owe it to yourself to start by reading the Propeller Manual.

    Your questions can have rather deep and long answers but as you are starting out you probably don't even need to know yet for the purposes of getting the device working and getting a feel for the device and the Propeller Tool.
  • StefanL38StefanL38 Posts: 2,292
    edited 2013-01-13 10:36
    Hi Alarus,

    welcome to the propeller-forum.

    there are two very different operation modes the cogs are working:

    1: interpreting SPIN if you start SPIN-code
    the SPIN-intepreter is loaded into the cog. All data and commands are taken frum the shared HUB-RAB (32kB)

    2: running Propeller-Assembler PASM: your assembler-code gets loaded from HUB-RAM to COG-RAM and starts.

    I don't know how many clockcycles this takes if I remember right it is in the microseconds range. (transferring 512 longs from HUB-RAM to cog-RAM.

    So for more detailed answers. Would you like to code in SPIN or PASM?

    best regards
    Stefan
  • pik33pik33 Posts: 2,367
    edited 2013-01-13 10:49
    Alarus wrote: »
    How to run Propeller?
    What is the first address for the program 0x0000 - 0x000F?
    How many clock cycles it takes to copy the program to the Cog?
    Can the program in assembly language to be more 0x1F0?
    How is the loading of programming in entered from the main memory?

    Thanks in advance.

    Q: How to run a Propeller?

    A: For beginners: buy one of Propeller board, install Propeller Tool or BST on your PC, connect the board with the PC with USB cable, add power supply if needed and start learning how to write programs for it.

    Q: What is the first address for the program 0x0000 - 0x000F?

    A: If I can remember, $0010. You don't need this information, simply write your program and Spin compiler will do the rest

    Q: How many clock cycles it takes to copy the program to the Cog?

    A: About 8000 cycles

    Q: Can the program in assembly language to be more 0x1F0?

    A: In normal mode, no. Cog has only $1F0 longs of program memory. There is LMM/XMM mode in which you can use longer asm programs.

    Q: How is the loading of programming in entered from the main memory?

    A. Use coginit or cognew. It loads program from main memory to cog memory and starts its execution from $0 address in cog memory.

    These are quick answers. Download and read a Propeller manual.
  • AlarusAlarus Posts: 48
    edited 2013-01-13 16:59
    Thanks to all who responded to my questions.
    My question is similar to a beginner, but have a deep meaning.

    I have a QuickStart board training. Questions arose when I wrote the program more 496 long words in assembler.

    I found out that the program is loaded during the 496 x 16 + 12 x 4 = 7984 cycles.
    16 cycles required to obtain a window from the main memory.
    12 teams (4 cycles per team) cleaning special registers.

    0x0000 in the address is the system bus.

    My program runs from 0x18 address. The manual says that to a 0x10.
  • kuronekokuroneko Posts: 3,623
    edited 2013-01-13 17:10
    Alarus wrote: »
    I found out that the program is loaded during the 496 x 16 + 12 x 4 = 7984 cycles.
    It's in fact closer to 8K cycles. But at this stage probably less important to you.
    Alarus wrote: »
    My program runs from 0x18 address. The manual says that to a 0x10.
    This varies with the size/structure of your program. So don't rely on hard-wried offsets too much.
  • AlarusAlarus Posts: 48
    edited 2013-01-13 17:22
    kuroneko wrote: »
    It's in fact closer to 8K cycles. But at this stage probably less important to you.


    This varies with the size/structure of your program. So don't rely on hard-wried offsets too much.

    You either know how many cycles it takes to download the program or do not know.
    I can say that it takes 7900 cycles to load, but it would not be correct as 8000.
  • kuronekokuroneko Posts: 3,623
    edited 2013-01-13 17:32
    8K (capital K) stands for 512*16. And even that isn't the exact amount (just a lower bound). The remainder depends an which cog is starting the other cog.
  • AlarusAlarus Posts: 48
    edited 2013-01-13 18:56
    Download over 496 long words in a single core is not possible or is there a mechanism for loading?
    And what model LMM XMM?
    In the Propeller Tool, I did not find them.
  • kuronekokuroneko Posts: 3,623
    edited 2013-01-13 19:52
    Alarus wrote: »
    Download over 496 long words in a single core is not possible or is there a mechanism for loading?
    I never claimed it is (assuming this is in response to my last posting). Starting a cog (from coginit to first insn) still takes 8K+ cycles.
    Alarus wrote: »
    And what model LMM XMM? In the Propeller Tool, I did not find them.
    Check out [thread=89640]this thread[/thread], AFAIK this is how it all began.
  • AlarusAlarus Posts: 48
    edited 2013-01-13 21:15
    kuroneko wrote: »
    I never claimed it is (assuming this is in response to my last posting). Starting a cog (from coginit to first insn) still takes 8K+ cycles.


    Check out [thread=89640]this thread[/thread], AFAIK this is how it all began.

    To use the LMM and XMM need to download a special operating system that will be loaded into the memory of the program.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-13 21:37
    LMM and XMM need to load a specific interpreter for the instruction set involved. This is not very different from the Spin interpreter although the Spin interpreter is provided in ROM. Because LMM and XMM directly execute some native Propeller instructions after moving them to locations in the cog used by the interpreter, speed of execution for LMM is intermediate between native execution and the Spin interpreter. XMM is much slower because the instructions are kept in external memory rather than in hub memory used for LMM and Spin execution. I would not call these interpreters an "operating system" since that implies a lot of support of high level I/O and other functions while these interpreters operate at very low levels.
  • AlarusAlarus Posts: 48
    edited 2013-01-13 22:08
    So use a 496 steps in the program is not possible without special drivers.
    And there is no mechanism for loading the program into memory Cog from main memory or Spin provides such a mechanism.
  • jazzedjazzed Posts: 11,803
    edited 2013-01-13 22:18
    An LMM extension is available for SPIN in the OBEX
    http://obex.parallax.com/objects/635/

    LMM is supported by PropBasic.
    Propeller-GCC, and Catalina support LMM and XMM modes.
    Propeller-GCC has an assembler that supports COG and LMM assembly.
    There is also an LMM assembler called LAS, but I've never used it successfully.

    LMM allows up to about 32KB of instructions.
    XMM is based on storing instructions in some external memory.
    Propeller-GCC allows up to 256MB of XMM/XMMC instructions.

    Spin provides mechanism to load PASM in COG cores with "cognew"
  • StefanL38StefanL38 Posts: 2,292
    edited 2013-01-13 23:33
    Hm, Alarus

    do you think 496 longs for high-speed drivers and 32kB SPIN-bytecode (which is more compact than f.e. c-code) for human interface is enough for what you are planning to do?

    If not switch over to another processor that provides more RAM.
    best regards
    Stefan
  • AlarusAlarus Posts: 48
    edited 2013-01-14 08:31
    Hi All.

    As a command Cognew also loads 496 long words from main memory or a single method?

    Who knows what is in the address $0000 - $000F main memory.
    I found out that the $0000 - this is the system bus frequency in Hertz.

    Thanks in advance.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-14 09:26
    COGNEW loads 496 long words from main memory into a cog. In Spin, there are two forms of COGNEW / COGINIT. One loads the 496 long words from a user specified block of main memory. The other loads the 496 long words starting at a specific location in ROM that contains the Spin interpreter. In addition, this 2nd form sets up parameters to the Spin interpreter so that it begins execution with the method call specified in the COGNEW / COGINIT call. The same thing (starting up a Spin interpreter) can be done with the COGNEW / COGINIT assembly instruction if you want.

    Attached is a description of the format of a Spin program including a description of the 16 byte preamble to the program that's stored in locations $00 to $0F of main memory (and the 1st 32K of the program EEPROM). The ROM bootloader uses this information when starting up the initial Spin interpreter in a cog. This information has been documented in several places. This happens to be an early copy I have around.
  • edited 2013-01-14 09:44
    I found this information on this forum somewhere. Don't know who posted it and can't guarantee it's accurate.

    Definition of the·initialization section (first 16 bytes) of the eeprom file
    Bytes :
    0-3 Clock speed
    4 : Clock Mode
    5 : Checksum
    6-7 : PBase - Start of object
    8-9 : VBase - Start of Variables
    10-11 : DBase - Start of Stack
    12-13 : PCurr - Pointer to start of first spin object to run
    14-15 : DCurr - Stack pointer

    I use the following PASM line to get the system clock frequency and it works okay
    rdlong count, #0

    Sandy
  • AlarusAlarus Posts: 48
    edited 2013-01-14 09:48
    Thank you very much!

    Now many of the points are clear.

    Is there a good simulator Propeller.
    I managed to find only Gear 1.11.0.0.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-14 09:56
    I believe Gear is the only simulator for native instructions. Most people run their code directly on the Propeller. There is a good debugger (ViewPort) that uses one cog to interface to a program running on a PC that allows you to set breakpoints, monitor variables, etc. in other cogs.

    In most cases, I've found it easier to debug on the Propeller itself. You can start up a VGA or TV text display in one cog and dedicate portions of the display buffer to any of several cogs. In assembly, it's relatively easy to take a value and convert it to hex for display in a few instructions so you can monitor data values. If you're writing in Spin mostly, it's even easier to make up complex displays of internal values.
  • jazzedjazzed Posts: 11,803
    edited 2013-01-14 12:34
    I like Dave Hein's spinsim which is a command line tool. I've never understood GEAR.
  • ericballericball Posts: 774
    edited 2013-01-14 13:32
    Alarus wrote: »
    Who knows what is in the address $0000 - $000F main memory.
    I found out that the $0000 - this is the system bus frequency in Hertz.

    Note: the contents of $0000-$000F are set by the bootloader & SPIN interpreter - not by the hardware. Thus, LONG[0] & LONG[4] is only the correct if the constants are set correctly in the SPIN file and the SPIN CLKSET command is used to change the clock settings.
  • Cluso99Cluso99 Posts: 18,069
    edited 2013-01-14 14:34
    i wrote a fast overlay loader for pasm - it is in the obex under tools iirc.
  • AlarusAlarus Posts: 48
    edited 2013-01-15 00:42
    How to determine the appropriate size of the stack to call Cognew?
  • StefanL38StefanL38 Posts: 2,292
    edited 2013-01-15 04:11
    Hi Alarus,

    the quick and dirty method is:

    if the method you are starting with has 1 to 3 parameters and only a few nested calls will occure choose a stacksise of 20-50 longs.
    If you have a lot of nested calls choose 200-1000 longs (depending on how much RAM you have left over)

    the quite serious and reliable method is
    http://obex.parallax.com/objects/25/



    The scientific precise answer is:

    analyse all the possible variations of nested calls of methods and all their parameters that can occure (and might occure in future when you change the code)
    and then there is surely (somewhere documented how many longs this will take)

    If I'm allowed to make a personal statement:
    you seem to be a perfectionist. You want to know it all before writing even the first line of code.
    If you do this as you're hobby everything is alright. If you try to work this way in a buissenes three other
    people that have the courage to get started easily will overtake you and beeing paid for beeing successful while you are still analysing
    some more details.

    Anyway to come close to the optimal number of longs needed for the stack there is this object to analyse this (empirical)
    mentioned above

    best regards
    Stefan
  • AlarusAlarus Posts: 48
    edited 2013-01-15 07:18
    Maybe I'm a perfectionist.
    I'm just very lazy and do everything once.
    Better to lose a week to the study, than a month fight the bugs.
  • jazzedjazzed Posts: 11,803
    edited 2013-01-15 08:03
    Alarus wrote: »
    Maybe I'm a perfectionist.
    I'm just very lazy and do everything once.
    Better to lose a week to the study, than a month fight the bugs.

    I certainly appreciate your effort. Many people have similar questions to yours after studying the manual.
    There will be more questions I'm sure and many others will ask instead of immediately discounting the chip.
    Propeller is very interesting to study.
  • StefanL38StefanL38 Posts: 2,292
    edited 2013-01-15 08:17
    Hi Alarus,
    I'm just very lazy and do everything once.
    Better to lose a week to the study, than a month fight the bugs.

    If you do it this way this is efficient too.

    best regards
    Stefan
  • AlarusAlarus Posts: 48
    edited 2013-01-15 08:37
    What a field FF FF F9 FF FF FF F9 FF at the end of the dump?
  • AlarusAlarus Posts: 48
    edited 2013-01-15 08:43
    I understand that the spin-code does not generate pasm.
  • StefanL38StefanL38 Posts: 2,292
    edited 2013-01-15 09:28
    HI Alarus,

    no the propellertool creates bytecode out of a spin-sourcefile. The SPIN (=bytecode) interpreter (written in PASM) is loaded into a cog and then the interpreter starrts fetching bytecode
    from HUB-RAM interpreting the bytecode. As SPIN is compiled to bytecode it is more space-efficient than high-language code comiled to native code. You win memory on the cost
    of execution-speed.

    best regards
    Stefan
Sign In or Register to comment.