Shop OBEX P1 Docs P2 Docs Learn Events
Catalina - Page 5 — Parallax Forums

Catalina

1235»

Comments

  • RossHRossH Posts: 5,462
    edited 2021-10-21 22:51

    Main things were getting the clock high enough (add "-C MHZ_260" to build settings).
    and, get coginit right in the .c driver file: //Note: Need to change coginit to _cogstart_PASM at end of this file

    Very nice. I'm sure @ersmith will fix the _cogstart_PASM issue.

    In the meantime, you don't need to edit any files, just add the missing definition to your catalina command.

    For instance, here are the commands I used to convert the Spin to C and then compile it ...

    spin2cpp.exe --p2 --ccode VGA_Simple1a.spin2
    catalina -p2  -lci -C P2_EVAL -C MHZ_260 test_spin2cpp.c -D "coginit=_cogstart_PASM"
    

    Ross.

  • @RossH : Thanks for your suggestions! I've added a #define __SPIN2CPP__ to the generated code, and put in a few more Catalina defines in the P1 case (as you say, it's too late to do much about propeller.h, but at least propeller2.h is mostly standard and we can make that work with all the compilers).

  • RossHRossH Posts: 5,462

    @ersmith said:
    @RossH : Thanks for your suggestions! I've added a #define __SPIN2CPP__ to the generated code, and put in a few more Catalina defines in the P1 case (as you say, it's too late to do much about propeller.h, but at least propeller2.h is mostly standard and we can make that work with all the compilers).

    Thanks. I've added _waitsec(), _waitms() and _waitus() as proper functions to Catalina's P1 and P2 libraries, including your suggestion about looping to allow arbitrarily long wait times. I'll issue a new release soon.

    Ross.

  • RossHRossH Posts: 5,462
    edited 2021-10-23 03:56

    ** post deleted ** - I've just realized this is not necessary!

  • RossHRossH Posts: 5,462

    Catalina 4.9.2 has been released. See the first post in this thread.

    @ersmith - this release adds spin2cpp.h, which should make it easier to add any new #defines you need to make spin2cpp work with Catalina.

  • RaymanRayman Posts: 14,640

    Ross, I'm not seeing the default P2 clock frequency being defined in the docs.
    But, I think it is 160 MHz, right?

  • RossHRossH Posts: 5,462

    @Rayman said:
    Ross, I'm not seeing the default P2 clock frequency being defined in the docs.
    But, I think it is 160 MHz, right?

    On the P2 the default is 180MHz - this is defined by the platform-specific constants specified in catalina_platforms.inc.

    I could arrange for these to be configurable on the command line, but there are so many fields to specify for the P2 clock and if they are not specified correctly then the program won't even start, so currently I have only added the two special cases that are needed by the VGA driver - i.e. MHZ_200 and MHZ_260.

    I will have a think about whether I should allow for the individual clock fields to be specified on the command line, but we would still have to have sensible defaults defined anyway. I took the view that it was better for the platform makers to specify what values are appropriate for their platforms. This was certainly the case on the P1, where different platforms used different crystals to overclock the P1 chip.

    In any case, I will update the documentation to make this clearer in the next release. Thanks.

    Ross.

  • RaymanRayman Posts: 14,640

    I think Chip came up with a scheme to auto-select the best clock settings based on the frequency.
    Think that's how Spin2 and FlexC work...

  • RossHRossH Posts: 5,462

    @Rayman said:
    I think Chip came up with a scheme to auto-select the best clock settings based on the frequency.
    Think that's how Spin2 and FlexC work...

    I'll look into it. But if they can't get the exact frequency requested, what values do they use? I guess I would have to do the same for consistency.

  • evanhevanh Posts: 15,915
    edited 2021-10-26 04:10

    @RossH said:
    I'll look into it. But if they can't get the exact frequency requested, what values do they use? I guess I would have to do the same for consistency.

    It has an allowable error - https://forums.parallax.com/discussion/comment/1486815/#Comment_1486815

  • evanhevanh Posts: 15,915
    edited 2021-10-26 08:10

    Doh! Turns out I had put a last minute bug in my outer testing routine. It wouldn't even compile. Fixed now.

  • RossHRossH Posts: 5,462

    Thanks, @evanh. I'll put something compatible into the next release.

    Every time I think I've gotten to the end of my "to do" list, people keep adding stuff! :)

    Ross.

  • RossHRossH Posts: 5,462
    edited 2021-11-10 01:23

    All

    I've just uploaded Catalina 4.9.3 to SourceForge. See the first post in this thread for details. Among other things, it adds the ability to specify the clock frequency on the command line (Propeller 2 only).

    Ross.

  • RossHRossH Posts: 5,462

    All

    I've just uploaded Catalina 4.9.4 to SourceForge. See the first post in this thread for details. The main thing this release adds is a new serial HMI option that saves a cog (Propeller 2 only). It also allows the serial baud rate to be specified on the command line (again, Propeller 2 only) and fixes a couple of very minor issues.

    Ross.

  • RossHRossH Posts: 5,462

    I was going to post this in the new C discussion thread, but then I decided my sense of humor might not be appreciated by some, so I decided to post it here instead!

    But what better demonstration of the usefulness of C on the Propeller than a compiler and interpreter for another language - in this case Lua - written entirely in C! :smile:

    Catalina has incorporated a version of Lua for while, but it was introduced when Lua was at version 5.1.4 and since that version does everything I need I have never seen a need to update it. However, Lua has come on a long way since then, so here is the latest and greatest - Lua 5.4.3. Catalina also compiles all intermediate versions of Lua, but some of them have issues, so if I update Catalina I have yet to decide which version to update to - but version 5.4.3 is getting almost too large to be useful on a micro controller, so I may stick with an earlier version but also include this version just to show what is possible.

    The demo is compiled specifically for a P2 EVAL board, but could be recompiled for other platforms. It is self-contained - you don't need Catalina installed to run it.

    Here is the README.TXT file:

               A demo of Catalina C - the Lua scripting language
               =================================================
    
    Catalina can be used to compile the Lua scripting language. Lua can be compiled
    for the Propeller 1 if equipped with External Memory, or for the Propeller 2.
    
    This demo is intendedfor the Propeller 2, and more specifically for the P2
    EVAL board. You do not need Catalina to just run the demo. However, all the 
    C sources to Lua are included if you do have Catalina installed and want to 
    recompile it yourself (e.g. for another P2 platform).
    
    The latest version of Lua is quite large (over 400kb) when compiled in NATIVE 
    mode, so for this demo it was compiled in COMPACT mode, which nearly halves 
    the executable size. This comes at the cost of slower execution speed, but, 
    it means there is enough Hub RAM left so that Lua can be used to run useful 
    programs.
    
    This version of Lua is 5.4.3 (the latest release). The compiled version in 
    this file was built for a P2 EVAL board to use the SIMPLE serial interface, 
    by using the command:
    
       build_all P2_EVAL SIMPLE VT100 COMPACT
    
    Lua is written in ANSI C, so it requires no source code modifcations to be
    compiled by Catalina. However, a new Makefile is required (Makefile.Catalina
    is in the Lua src directory). The build_all script uses this Makefile 
    automatically.
    
    To run Lua, copy all the files in the SDCARD directory to an SD card, make 
    sure all the microswitches on the P2 EVAL board are set to off (to boot from 
    the SD card) and insert the card into the P2 EVAL board. The files other than
    the Lua files are part of Catalina's Catalyst SD card program loader - see 
    Catalina for more details.
    
    Catalina's payload loader, which we will use as a simple terminal emulator, is
    also included. This can be executed from a Windows command line as follows 
    (where X is the number of the serial port connected to the P2 EVAL board):
    
       payload -i -b230400 -pX
    
    Reset the P2 and you should see a prompt like:
    
       Catalyst 4.9
       >
    
    Enter the following command to load Lua and execute the "life" demo program:
    
       lua life.lua
    
    You can instead use the Lua compiler to compile the program, and then load
    the compiled version (compiling can make Lua programs load faster, but in
    this case makes very little difference):
    
       luac -o l.out life.lua
       lua l.out
    
    You can use the vi text editor to view and edit the demo program:
    
       vi life.lua 
    
    (in vi, type :help to get help, or :q! to quit)
    
    If you are familiar with Lua, you can also execute Lua in interactive mode.
    Enter the command:
    
       lua
    
    From within Lua, try some simple Lua statements:
    
       print("Hello World")
       a=1
       b=2
       print(a+b)
    
    Or, you can load and execute the demo program:
    
       dofile("life.lua")
    
    

    Ross.

  • RossHRossH Posts: 5,462
    edited 2021-12-15 03:11

    Just a quick note about compiling Lua 5.4.3 with Catalina. If you enable optimization, the compilation fails with a "Symbol table is full" message. This is because the optimizer adds symbols used to calculate relative jumps, and the p2asm assembler can't cope (the file it is assembling is 150,000 lines of PASM).

    In the next release of Catalina I will expand the p2asm assembler symbol table to 20,000 symbols. If you do that, it compiles ok with or without optimization. You can fix this yourself if you want to recompile Catalina.

    In the file Catalina\source\p2asm_src\symsubs.h, change line 96 from ...

    #define MAX_SYMBOLS 10000

    ... to ...

    #define MAX_SYMBOLS 20000

    I will fix this in the next release.

  • evanhevanh Posts: 15,915

    Ross,
    Not sure what you've referenced of my clock setting code linked above but I just fixed a regression in the div33() function. The extra code does integer rounding to nearest with IEEE de-biasing on exact .5 results. Nice to have feature.

  • RossHRossH Posts: 5,462

    The latest release of Catalina is now in [url="https://forums.parallax.com/discussion/174158/catalina-ansi-c-for-the-propeller-1-2/p1"]this thread[/url] for both the P1 and P2.

    Ross.

Sign In or Register to comment.