Shop OBEX P1 Docs P2 Docs Learn Events
I have begun my Propeller 2 journey! - Page 4 — Parallax Forums

I have begun my Propeller 2 journey!

124678

Comments

  • RossHRossH Posts: 5,462

    All in all I am a happy camper :-)

    Good luck with it. By the way, this was a good suggestion from jmg earlier ...

    @jmg said:
    @enorton said:

    89k including comments. Actual lines of C code are about 80k but as I said earlier it will likely grow. I'm not worried about that much at the moment.

    I would be worried about if this will all fit inside P2.

    @enorton said:
    XMOS is better aligned with what I want to do. My application requires high-speed and reliable protocols that I don't have to spend hours trying to figure out how to create. ...
    I was able to create what I needed in the XMOS IDE and it took me less than a few hours to do.

    What binary size resulted from your XMOS build ?
    What binary size and what MCU do you currently run this code on ?

    If you have compiled your project for ANY processor (including INTEL) it should give you a significant clue as to whether or not it will fit on the Propeller.

    Ross.

  • jmgjmg Posts: 15,173

    @enorton said:

    I have not tried the XMOS device as I am trying like hell to get the propeller chip to work. I currently run my code on the STM32H723 high-performance microcontroller.
    It is 550 MHz and runs ok but bogs down when data gets heavy which has been the case for other micros as well.
    I am hoping with extra processors I can take some of the load off the main processor by sharing the load...
    Sorry, forgot to mention the code size on the current chip STM32H723 which is a little under 180k

    Ah, so you are looking more to partition things between P2 and the H7 ?
    That should ease the risk of simply running out of code space.

  • @jmg said:

    @enorton said:

    I have not tried the XMOS device as I am trying like hell to get the propeller chip to work. I currently run my code on the STM32H723 high-performance microcontroller.
    It is 550 MHz and runs ok but bogs down when data gets heavy which has been the case for other micros as well.
    I am hoping with extra processors I can take some of the load off the main processor by sharing the load...
    Sorry, forgot to mention the code size on the current chip STM32H723 which is a little under 180k

    Ah, so you are looking more to partition things between P2 and the H7 ?
    That should ease the risk of simply running out of code space.

    H7 is "almost" there but not quite there. Yes, it is fast but that's where things stop performance-wise. I have too many interrupts firing all over the place so I need parallel processing to get around my issue so now I am going with the Propeller 2 only turbocharged of course to see if it will be an answered prayer OR not but suspect by the time this is all over and done with, I will have something working, gray hair and bald spots on my head lol.

  • RossHRossH Posts: 5,462

    @enorton

    One last thing - I normally allow for 20,000 symbols in Catalina's assembler symbol table, which is enough to compile my largest program (35,000 SLOC) but it might not be enough to compile yours (89,000 SLOC). But I just tested it with 200,000 symbols and it works fine. You might need to have 60,000 symbols.

    I don't want to just bump up the number of symbols for everyone unnecessarily, because it slows down the assembly process for all programs - but a 60,000 symbol version is attached - just update the version of p2asm.exe in Catalina's bin directory.

    Or you can change it yourself and then recompile the assembler. It's a one line change in source\p2asm_src\symsubs.h. Look for the following:

    #ifdef __P2GCC__
    #define MAX_SYMBOLS    1000
    #else
    #define MAX_SYMBOLS    20000  
    #endif
    

    Just change 20000 to whatever you want, then do build_all in this directory (note you will need MinGW installed).

    Ross.

  • @RossH said:
    @enorton

    One last thing - I normally allow for 20,000 symbols in Catalina's assembler symbol table, which is enough to compile my largest program (35,000 SLOC) but it might not be enough to compile yours (89,000 SLOC). But I just tested it with 200,000 symbols and it works fine. You might need to have 60,000 symbols.

    I don't want to just bump up the number of symbols for everyone unnecessarily, because it slows down the assembly process for all programs - but a 60,000 symbol version is attached - just update the version of p2asm.exe in Catalina's bin directory.

    Or you can change it yourself and then recompile the assembler. It's a one line change in source\p2asm_src\symsubs.h. Look for the following:

    #ifdef __P2GCC__
    #define MAX_SYMBOLS    1000
    #else
    #define MAX_SYMBOLS    20000  
    #endif
    

    Just change 20000 to whatever you want, then do build_all in this directory (note you will need MinGW installed).

    Ross.

    Ok sweet will do and thank you :-D. While I have you is there a way to do interrupts for pin input events? I really don't want to take up a cog for a few input pins.

    I am making good progress going through all the errors. It will take another couple of hours but hey who needs sleep right lol.

    One other thing... I am going to use two UARTS for my project and I will keep the "programming" port 230400 baud but need the other UART to be 115200 baud. Which file do I look for/modify to make this adjustment?

    And yet another thing and I hate to bring up something you already mentioned but I feel stupid and confused about the flash on the development kit and the SD card slot. I'd like to have the SD card hold the main program. That way the customer can update the firmware for the board relatively easily through their computer whether it is WIndows 10, 11, MAC, Linux, Ubuntu whatever. They have the means to do it themselves if I send them the updated firmware. How do I do this exactly? What bells and whistles do I need to configure to make this work?

    Many thanks for all your help :)

  • RossHRossH Posts: 5,462

    @enorton said:

    While I have you is there a way to do interrupts for pin input events? I really don't want to take up a cog for a few input pins.

    Yes. There is an example of using interrupts (counter interrupts in the example, but other interrupt types should be no problem) in the demos\interrupts folder. See the README.Interrupts file in that folder.

    One other thing... I am going to use two UARTS for my project and I will keep the "programming" port 230400 baud but need the other UART to be 115200 baud. Which file do I look for/modify to make this adjustment?

    For the two port serial plugin, look in the platform.inc file in the target folder. It depends on which board you are using:

    target\P2_EDGE.inc for the P2 EDGE board.
    target\P2_EVAL.inc for the P2 Evaluation board.
    target\P2_CUSTOM.inc for other platforms.

    You will find a section like the following (this one is from P2_CUSTOM.inc):

    ' 2 Port Serial constants
    ' =======================
    
    ' Note that for P2_CUSTOM, the second serial port is set up to accommodate a PropPlug on pins 50 & 52
    
    _RX1_PIN   = _RX_PIN
    _TX1_PIN   = _TX_PIN
    _RX1_MODE  = %0000_0000_000_0000000000000_00_11111_0 ' async rx mode, true input, input  enabled for smart input
    _TX1_MODE  = %0000_0000_000_0000000000000_01_11110_0 ' async tx mode, true output, output enabled for smart output
    _BAUDRATE1 = _BAUDRATE
    _RX2_PIN   = 50
    _TX2_PIN   = 52
    _RX2_MODE  = %0000_0000_000_0000000000000_00_11111_0 ' async rx mode, true input, input  enabled for smart input
    _TX2_MODE  = %0000_0000_000_0000000000000_01_11110_0 ' async tx mode, true output, output enabled for smart output
    _BAUDRATE2 = _BAUDRATE
    

    Modify _BAUDRATE1 and/or _BAUDRATE2. I have never tried using different baud rates. But it should be fine.

    And yet another thing and I hate to bring up something you already mentioned but I feel stupid and confused about the flash on the development kit and the SD card slot. I'd like to have the SD card hold the main program. That way the customer can update the firmware for the board relatively easily through their computer whether it is WIndows 10, 11, MAC, Linux, Ubuntu whatever. They have the means to do it themselves if I send them the updated firmware. How do I do this exactly? What bells and whistles do I need to configure to make this work?

    Easy. Just program Catalyst (Catalina's SD Card program loader) into FLASH using flash_payload and put your own program on the SD card and away you go. You can set Catalyst up to always execute a specific program on boot by adding a file called AUTOEXEC.TXT to the SD Card which (as the name implies) is just a text file containing the command to execute. See the Catalyst Reference Manual for more details.

    Ross.

  • @RossH said:

    @enorton said:

    While I have you is there a way to do interrupts for pin input events? I really don't want to take up a cog for a few input pins.

    Yes. There is an example of using interrupts (counter interrupts in the example, but other interrupt types should be no problem) in the demos\interrupts folder. See the README.Interrupts file in that folder.

    One other thing... I am going to use two UARTS for my project and I will keep the "programming" port 230400 baud but need the other UART to be 115200 baud. Which file do I look for/modify to make this adjustment?

    For the two port serial plugin, look in the platform.inc file in the target folder. It depends on which board you are using:

    target\P2_EDGE.inc for the P2 EDGE board.
    target\P2_EVAL.inc for the P2 Evaluation board.
    target\P2_CUSTOM.inc for other platforms.

    You will find a section like the following (this one is from P2_CUSTOM.inc):

    ' 2 Port Serial constants
    ' =======================
    
    ' Note that for P2_CUSTOM, the second serial port is set up to accommodate a PropPlug on pins 50 & 52
    
    _RX1_PIN   = _RX_PIN
    _TX1_PIN   = _TX_PIN
    _RX1_MODE  = %0000_0000_000_0000000000000_00_11111_0 ' async rx mode, true input, input  enabled for smart input
    _TX1_MODE  = %0000_0000_000_0000000000000_01_11110_0 ' async tx mode, true output, output enabled for smart output
    _BAUDRATE1 = _BAUDRATE
    _RX2_PIN   = 50
    _TX2_PIN   = 52
    _RX2_MODE  = %0000_0000_000_0000000000000_00_11111_0 ' async rx mode, true input, input  enabled for smart input
    _TX2_MODE  = %0000_0000_000_0000000000000_01_11110_0 ' async tx mode, true output, output enabled for smart output
    _BAUDRATE2 = _BAUDRATE
    

    Modify _BAUDRATE1 and/or _BAUDRATE2. I have never tried using different baud rates. But it should be fine.

    And yet another thing and I hate to bring up something you already mentioned but I feel stupid and confused about the flash on the development kit and the SD card slot. I'd like to have the SD card hold the main program. That way the customer can update the firmware for the board relatively easily through their computer whether it is WIndows 10, 11, MAC, Linux, Ubuntu whatever. They have the means to do it themselves if I send them the updated firmware. How do I do this exactly? What bells and whistles do I need to configure to make this work?

    Easy. Just program Catalyst (Catalina's SD Card program loader) into FLASH using flash_payload and put your own program on the SD card and away you go. You can set Catalyst up to always execute a specific program on boot by adding a file called AUTOEXEC.TXT to the SD Card which (as the name implies) is just a text file containing the command to execute. See the Catalyst Reference Manual for more details.

    Ross.

    Thank you so much Ross. I really appreciate it :-D. Have a good night and I will fill you in with details as I progress.

    One thing I'm having a little trouble with is union/struct combo that works for the other IDEs but throws a fit in Catalina. I will continue tomorrow and if I get stuck I may reach out.

  • RossHRossH Posts: 5,462
    edited 2023-04-13 03:31

    @enorton said:

    One thing I'm having a little trouble with is union/struct combo that works for the other IDEs but throws a fit in Catalina. I will continue tomorrow and if I get stuck I may reach out.

    I am guessing this is a problem with anonymous structs or unions. These were problematic in both C and C++ for a long time. They were first added to various compilers as compiler-specific extensions, and eventually came into the C and C++ standards but individually and at different times (unions first, then structs IIRC). So for a long time they were simply best avoided altogether. Even now, they are generally ok in C but they can still be problematic in C++, since C++ has to impose additional limitations on their use.

    In most cases, anonymous structs and unions are just syntactic "sugar" and are not really necessary. Just add names to the anonymous elements and then the compiler will tell you where you need to fix any references this breaks.

    For example, the following will compile with gcc (some versions!) but not with Catalina:

    typedef struct {
        union {
           struct {
              float x, y, z;
           };               // <-- no name = anonymous struct
           float xyz[3];
        };                  // <-- no name = anonymous union
    } str;
    
    void main() {
      str s;
      s.x = 1.0;
    }
    

    Add a couple of names, and it won't compile with either gcc or Catalina :( ... but the compiler will tell you what you need to fix. For instance:

    typedef struct {
        union {
           struct {
              float x, y, z;
           } a;             // <-- added name 'a'
           float xyz[3];
        } b;                // <-- added name 'b'
    } str;
    
    void main() {
      str s;
      s.x = 1.0;            // now 's.x' is undefined!
    }
    

    Now both gcc and Catalina will generate an error telling you that struct str has no member (or field) x - so s.x now has to be changed to s.b.a.x. Then it will compile with either gcc (any version) or Catalina.

    Sure, the new code is a bit less elegant, but it is now portable across all C and C++ compilers.

    Ross.

  • enortonenorton Posts: 144
    edited 2023-04-13 06:09

    @RossH said:

    @enorton said:

    One thing I'm having a little trouble with is union/struct combo that works for the other IDEs but throws a fit in Catalina. I will continue tomorrow and if I get stuck I may reach out.

    I am guessing this is a problem with anonymous structs or unions. These were problematic in both C and C++ for a long time. They were first added to various compilers as compiler-specific extensions, and eventually came into the C and C++ standards but individually and at different times (unions first, then structs IIRC). So for a long time they were simply best avoided altogether. Even now, they are generally ok in C but they can still be problematic in C++, since C++ has to impose additional limitations on their use.

    In most cases, anonymous structs and unions are just syntactic "sugar" and are not really necessary. Just add names to the anonymous elements and then the compiler will tell you where you need to fix any references this breaks.

    For example, the following will compile with gcc (some versions!) but not with Catalina:

    typedef struct {
        union {
           struct {
              float x, y, z;
           };               // <-- no name = anonymous struct
           float xyz[3];
        };                  // <-- no name = anonymous union
    } str;
    
    void main() {
      str s;
      s.x = 1.0;
    }
    

    Add a couple of names, and it won't compile with either gcc or Catalina :( ... but the compiler will tell you what you need to fix. For instance:

    typedef struct {
        union {
           struct {
              float x, y, z;
           } a;             // <-- added name 'a'
           float xyz[3];
        } b;                // <-- added name 'b'
    } str;
    
    void main() {
      str s;
      s.x = 1.0;            // now 's.x' is undefined!
    }
    

    Now both gcc and Catalina will generate an error telling you that struct str has no member (or field) x - so s.x now has to be changed to s.b.a.x. Then it will compile with either gcc (any version) or Catalina.

    Sure, the new code is a bit less elegant, but it is now portable across all C and C++ compilers.

    Ross.

    Ah ok well that seems like a good way to do it. I did it this way:

    typedef union
    {
        struct
        {
            unsigned int x:1; // X Limit input
            unsigned int y:1; // Y Limit input
            unsigned int z:1; // Z Limit input
            unsigned int padding:5; // Padding bits
        }pins_t;
        uint8_t pins_reg_byte;
    
    }pins_reg_t;
    
    pins_reg_t    pins_reg;
    

    Then to access the pins:

    pins_reg.pins_t.x = 1;

    So far, the compiler hasn't complained, and I can read and write to the bits or access them as a byte :-).

    One question I have, is there a way to access say 8 or 16 bits as a port with the Propeller 2 chip? I looked in the datasheet and the propeller2.h file and I see only pins mentioned but nothing about ports. Any tricks I could use to access a group of 8 to 16 pins at the same time? I know I could do _pinh or _pinl but want all bits to go out at the same time if that makes sense.

  • @enorton

    A little tip on posting code, to make it easier to read and preserve formatting...

    Use three backticks to surround a code block

    Use single backticks to surround a single line or inline code snippet.

    I've updated your post above so you can edit it and see the technique if you'd like.

    All the best.

  • @VonSzarvas said:
    @enorton

    A little tip on posting code, to make it easier to read and preserve formatting...

    Use three backticks to surround a code block

    Use single backticks to surround a single line or inline code snippet.

    I've updated your post above so you can edit it and see the technique if you'd like.

    All the best.

    Ok great and thank you for sharing :-)

  • RossHRossH Posts: 5,462

    @enorton said:

    One question I have, is there a way to access say 8 or 16 bits as a port with the Propeller 2 chip? I looked in the datasheet and the propeller2.h file and I see only pins mentioned but nothing about ports. Any tricks I could use to access a group of 8 to 16 pins at the same time? I know I could do _pinh or _pinl but want all bits to go out at the same time if that makes sense.

    Perhaps I am not understanding what you mean. Just use the special registers INA or INB (or OUTA and OUTB) to manipulate up to 32 pins at once.

  • RossHRossH Posts: 5,462
    edited 2023-04-13 06:55

    Also, in Catalina, if you #include <propeller.h> then the special registers (INA, INB, OUTA, OUTB, DIRA, DIRB etc) all become special symbols, so you can just say things like:

    #include <propeller.h>
    
    void main() {
      register int x;
    
      DIRA = 0x00FF;
      OUTA |= 0x00AA;
      x = INA;
    }
    
  • @RossH said:

    @enorton said:

    One question I have, is there a way to access say 8 or 16 bits as a port with the Propeller 2 chip? I looked in the datasheet and the propeller2.h file and I see only pins mentioned but nothing about ports. Any tricks I could use to access a group of 8 to 16 pins at the same time? I know I could do _pinh or _pinl but want all bits to go out at the same time if that makes sense.

    Perhaps I am not understanding what you mean. Just use the special registers INA or INB (or OUTA and OUTB) to manipulate up to 32 pins at once.

    ok great thank you Ross. I finally got through all the errors and fixed all of them but two.. I need trunc() and round(). Does Catalina Geany support these functions? If so, what library do I use? Right now, I am doing -lm and adding math.h. I checked math.h and it doesn't have them listed. How do you suppose I get these for the project? Thanks for all the help :-)

  • RossHRossH Posts: 5,462

    @enorton said:

    I need trunc() and round(). Does Catalina Geany support these functions? If so, what library do I use? Right now, I am doing -lm and adding math.h. I checked math.h and it doesn't have them listed. How do you suppose I get these for the project? Thanks for all the help :-)

    The trunc() and round() functions are not standard ANSI math functions, so they are not defined in the standard math library (which is the one used by -lm).

    However, I added them (along with some other functions) to Catalina's own maths libraries - just use -lma or -lmb or -lmc instead of -lm. On the Propeller 2, -lmc is recommended - the others are maintained only for backwards compatibility with the Propeller 1.

    Note: -lmc uses a floating point co-processor cog, whereas -lm doesn't (it implements all floating point in software). If you really want to use -lm to save a cog, you will have to add trunc() and round() functions to your own program. Suitable C implementations should be easy to find.

    Ross.,

  • @RossH said:

    @enorton said:

    I need trunc() and round(). Does Catalina Geany support these functions? If so, what library do I use? Right now, I am doing -lm and adding math.h. I checked math.h and it doesn't have them listed. How do you suppose I get these for the project? Thanks for all the help :-)

    The trunc() and round() functions are not standard ANSI math functions, so they are not defined in the standard math library (which is the one used by -lm).

    However, I added them (along with some other functions) to Catalina's own maths libraries - just use -lma or -lmb or -lmc instead of -lm. On the Propeller 2, -lmc is recommended - the others are maintained only for backwards compatibility with the Propeller 1.

    Note: -lmc uses a floating point co-processor cog, whereas -lm doesn't (it implements all floating point in software). If you really want to use -lm to save a cog, you will have to add trunc() and round() functions to your own program. Suitable C implementations should be easy to find.

    Ross.,

    This is perfect thank you. I will use the -lmc since I will have a couple cogs left over so might as well share the load. I noticed you mentioned the serial library takes a cog and the math co-processor takes a cog. Do the libraries take the first cogs (cog0 and cog1) and the main function gets cog2 and then other cogs that I use follow after cog2 for instance cog3, cog4 etc? I'm just trying to wrap my head around this whole multi-processor idea.

  • evanhevanh Posts: 15,915
    edited 2023-04-13 08:29

    The hardware instruction COGINIT has a bit to specify to use any free cog. So generally you get whatever is free. Each cog can be "stopped". So I guess COGINIT uses this stopped state as a bitmap of free cogs.

    EDIT: Nitty gritty is in the Silicon Documentation (Google Doc) under heading of STARTING AND STOPPING COGS -https://www.parallax.com/propeller-2/documentation/

  • RossHRossH Posts: 5,462

    @enorton said:

    This is perfect thank you. I will use the -lmc since I will have a couple cogs left over so might as well share the load. I noticed you mentioned the serial library takes a cog and the math co-processor takes a cog. Do the libraries take the first cogs (cog0 and cog1) and the main function gets cog2 and then other cogs that I use follow after cog2 for instance cog3, cog4 etc? I'm just trying to wrap my head around this whole multi-processor idea.

    Actually, just hold off on using -lmc for a bit. Since they are not ANSI functions, I don't have either trunc() or round() in my standard release test suite, so I thought I had better test them and it seems there may be a problem there. Not sure what is going on, but I will investigate and fix if necessary.

    In the meantime, attached is trunc_round.c which you can just add to your project for use with -lm (this does work - I just tested it!)

    On the cog allocation, there is no guarantee which cog is used for what. But except in unusual circumstances you generally don't care - the Propeller just chooses a free cog and you can just forget about it (but you can find out what cogs are in use if you want to - there is a function called display_registry() in the Catalina demo program ex_registry.c which you can copy to your own program if you want to find out.

    Ross.

  • RossHRossH Posts: 5,462
    edited 2023-04-13 11:55

    Ok! Silly me!

    Catalina's version of trunc() and round() return an int, and I was expecting a float!

    The stand-alone versions I posted do return floats, so for the moment you can use those (with -lm) if that is what you need.

    I'll have to have a think about whether to change Catalina's versions to return floats, or else provide another version for those people who need that.

    Ross.

  • RossHRossH Posts: 5,462

    @evanh said:
    The hardware instruction COGINIT has a bit to specify to use any free cog. So generally you get whatever is free. Each cog can be "stopped". So I guess COGINIT uses this stopped state as a bitmap of free cogs.

    EDIT: Nitty gritty is in the Silicon Documentation (Google Doc) under heading of STARTING AND STOPPING COGS -https://www.parallax.com/propeller-2/documentation/

    Yes, I probably should have added that with Catalina you can specify a specific cog if you want to do so, but if you do not then there is no guarantee which order cogs will be used. It can depend on many things, including what other plugins are in use and also on how the program is started. For example, if a program is started by the Catalyst SD Card program loader, then Catalyst needs to use some cogs during the program load process, so plugins may not end up in the same cogs as they would if the same was program serially (of course, the cogs used by the loader are then freed so that they can be used by the program).

    Ross.

  • @evanh said:
    The hardware instruction COGINIT has a bit to specify to use any free cog. So generally you get whatever is free. Each cog can be "stopped". So I guess COGINIT uses this stopped state as a bitmap of free cogs.

    EDIT: Nitty gritty is in the Silicon Documentation (Google Doc) under heading of STARTING AND STOPPING COGS -https://www.parallax.com/propeller-2/documentation/

    Thank you for this.

  • @RossH said:

    @evanh said:
    The hardware instruction COGINIT has a bit to specify to use any free cog. So generally you get whatever is free. Each cog can be "stopped". So I guess COGINIT uses this stopped state as a bitmap of free cogs.

    EDIT: Nitty gritty is in the Silicon Documentation (Google Doc) under heading of STARTING AND STOPPING COGS -https://www.parallax.com/propeller-2/documentation/

    Yes, I probably should have added that with Catalina you can specify a specific cog if you want to do so, but if you do not then there is no guarantee which order cogs will be used. It can depend on many things, including what other plugins are in use and also on how the program is started. For example, if a program is started by the Catalyst SD Card program loader, then Catalyst needs to use some cogs during the program load process, so plugins may not end up in the same cogs as they would if the same was program serially (of course, the cogs used by the loader are then freed so that they can be used by the program).

    Ross.

    Oh ok very interesting :-). As soon as I get through the front-end stuff I will address the cog/processor details.

    On a good note, the project compiled, and I have downloaded it into the chip, and the front end of the firmware works. I have serial communication, eeprom reading, and writing settings etc. so I am a happy camper :). Serial communication is working great btw. There is one function I need to add to -lserial2 library and need access to the source if possible. I need to add an rx buffer size check to see how much rx buffer is available for the host to send more data if it is needed. What and where is the source for this and how easy is it to modify and then compile the library for use with Catalina Geany? I really hate to be a major PITA and I am sure I have been a thorn in the posterior :-(.

  • @RossH said:

    @evanh said:
    The hardware instruction COGINIT has a bit to specify to use any free cog. So generally you get whatever is free. Each cog can be "stopped". So I guess COGINIT uses this stopped state as a bitmap of free cogs.

    EDIT: Nitty gritty is in the Silicon Documentation (Google Doc) under heading of STARTING AND STOPPING COGS -https://www.parallax.com/propeller-2/documentation/

    Yes, I probably should have added that with Catalina you can specify a specific cog if you want to do so, but if you do not then there is no guarantee which order cogs will be used. It can depend on many things, including what other plugins are in use and also on how the program is started. For example, if a program is started by the Catalyst SD Card program loader, then Catalyst needs to use some cogs during the program load process, so plugins may not end up in the same cogs as they would if the same was program serially (of course, the cogs used by the loader are then freed so that they can be used by the program).

    Ross.

    Btw the basic functionality code size is without the added stuff I need to add later is:

    code = 86708 bytes
    cnst = 2916 bytes
    init = 64 bytes
    data = 44856 bytes
    file = 146816 bytes

    When I add the backend functionality with added cog support I am sure the usage will increase but we will see how much.

  • RossHRossH Posts: 5,462
    edited 2023-04-14 00:06

    @enorton said:
    There is one function I need to add to -lserial2 library and need access to the source if possible. I need to add an rx buffer size check to see how much rx buffer is available for the host to send more data if it is needed. What and where is the source for this and how easy is it to modify and then compile the library for use with Catalina Geany? I really hate to be a major PITA and I am sure I have been a thorn in the posterior :-(.

    You already have all the sources to Catalina and the libraries, although you may not have installed them when you installed Catalina (it is an option in the setup program).

    The plugin itself is written in PASM and is in the target_p2 folder (cogserial.pasm). The C library "wrappers" are a rewrite of the original Spin functions, and are in the source\lib\catalina_serial2 folder.

    Adding a function to check the size of the rx buffer should be possible. The only problem might be finding sufficient space in the plugin. I will have a look when I get some time. The original was written by @msrobots (Michael Sommer) - if he is still around the forums, then he may be able to help.

    I would not bother making it possible to compile the libraries with Geany - there is a single build_all script in source\lib that will rebuild the entire Catalina library.

    Ross.

  • RossHRossH Posts: 5,462

    @RossH said:

    Catalina's version of trunc() and round() return an int, and I was expecting a float!

    I have decided what to do here. In the next release I will rename Catalina's existing round() and trunc() function to lround() and ltrunc(). These will return longs, and this is what the equivalent functions are called in C99. I will add new versions called dround() and dtrunc() which return doubles. Then you can choose which ones to use in your program just by adding suitable #defines.

    Or you can include the versions of round() and trunc() I posted earlier in this thread. Currently, there is a name conflict with all library options except -lm, but this change will also fix that so they can then be used with any of the math libraries.

    Ross.

  • RossHRossH Posts: 5,462

    @enorton said:

    Btw the basic functionality code size is without the added stuff I need to add later is:

    code = 86708 bytes
    cnst = 2916 bytes
    init = 64 bytes
    data = 44856 bytes
    file = 146816 bytes

    When I add the backend functionality with added cog support I am sure the usage will increase but we will see how much.

    Looks like you have plenty of headroom, and you won't need to use any of Catalina's memory saving or memory extension options.

    Ross.

  • @RossH said:

    @enorton said:
    There is one function I need to add to -lserial2 library and need access to the source if possible. I need to add an rx buffer size check to see how much rx buffer is available for the host to send more data if it is needed. What and where is the source for this and how easy is it to modify and then compile the library for use with Catalina Geany? I really hate to be a major PITA and I am sure I have been a thorn in the posterior :-(.

    You already have all the sources to Catalina and the libraries, although you may not have installed them when you installed Catalina (it is an option in the setup program).

    The plugin itself is written in PASM and is in the target_p2 folder (cogserial.pasm). The C library "wrappers" are a rewrite of the original Spin functions, and are in the source\lib\catalina_serial2 folder.

    Adding a function to check the size of the rx buffer should be possible. The only problem might be finding sufficient space in the plugin. I will have a look when I get some time. The original was written by @msrobots (Michael Sommer) - if he is still around the forums, then he may be able to help.

    I would not bother making it possible to compile the libraries with Geany - there is a single build_all script in source\lib that will rebuild the entire Catalina library.

    Ross.

    After searching through the files, I did find cogserial.pasm. I'm not in a huge rush for it as I have other issues I need to address like adding timer functionality and other functions which I am working on now. When you are ready to add it I can send you the function I used to check the rx ring buffer size if that helps.

  • RossHRossH Posts: 5,462

    @enorton said:

    After searching through the files, I did find cogserial.pasm. I'm not in a huge rush for it as I have other issues I need to address like adding timer functionality and other functions which I am working on now. When you are ready to add it I can send you the function I used to check the rx ring buffer size if that helps.

    Send it to me or just post it here. I will include it in the next release.

    Ross.

  • @RossH said:

    @enorton said:

    After searching through the files, I did find cogserial.pasm. I'm not in a huge rush for it as I have other issues I need to address like adding timer functionality and other functions which I am working on now. When you are ready to add it I can send you the function I used to check the rx ring buffer size if that helps.

    Send it to me or just post it here. I will include it in the next release.

    Ross.

    How can I send it to you? If I post it here then it's public.. Let me know.

  • @RossH said:

    @RossH said:

    Catalina's version of trunc() and round() return an int, and I was expecting a float!

    I have decided what to do here. In the next release I will rename Catalina's existing round() and trunc() function to lround() and ltrunc(). These will return longs, and this is what the equivalent functions are called in C99. I will add new versions called dround() and dtrunc() which return doubles. Then you can choose which ones to use in your program just by adding suitable #defines.

    Or you can include the versions of round() and trunc() I posted earlier in this thread. Currently, there is a name conflict with all library options except -lm, but this change will also fix that so they can then be used with any of the math libraries.

    Ross.

    I think what you outlined sounds good.

    I tried the -lmc and trunc and round seem to work. I will test further after I get the timer stuff ironed out to make sure there are no issues.

Sign In or Register to comment.