Shop OBEX P1 Docs P2 Docs Learn Events
PropGCC and the C3 — Parallax Forums

PropGCC and the C3

RsadeikaRsadeika Posts: 3,837
edited 2013-08-26 13:05 in Propeller 1
Since it has been mentioned, in some other threads, that in September there will be some major announcements about SimpleIDE/PropGCC, I thought that I should get back in and check out some of the new libs that have been added. It has been noted that the libs, that are being presented in the Learn area, are not necessarily ANSI specific, which I do not have a problem with, as long as there is a big note some where that states that.

A couple of things that I should mention, the big thing with the Propeller is, the cogs. The big thing with PropGCC is, use of expanded/extended memory(XMM). In the Learn section I do not see any preliminary discussion about, maybe using all eight cogs, and being able to use all the cogs in all of the memory modes(LMM,CMM,XMM). I think that some of the new people will start asking - What about the Propellers cogs, how do we use them.

Below is my sample program where I am trying to make use of my C3 board. One thing that I did notice, when you use print() and writeLine(), there is an auto CR with it. It seems like, when you try to use it in an IO format, you get that unwanted CR.

The other thing I noticed is when you create a new project, it no longer creates a specific folder. Also, in the main() you have a couple curly brackets({}), but you do not have a while() associated with it. Does this mean that there is an assumed while(1) associated with that in the main() subroutine?

Ray

/******************************************************************************/
/*
*  C3test2.c
*
* August 24, 2013
*
*/
#include "simpletools.h"
#include "fdserial.h"

/* XBee to run in its own cog, only works with LMM and CMM. */
void XBee(void *par);
unsigned int XBstack[40 + 25];
/* Test run of another cog run, only works with LMM and CMM. */
void LedNF(void *par);
unsigned int Ledstack[40 + 25];

/******************************************************************************/
int main() 
{
  // Add startup code here.
  char inBuff[40];
  int getBuff;

  pause(300);
  print("This is C3test2\n");

/* Start the cogs. */
  cogstart(&LedNF, NULL, Ledstack, sizeof(Ledstack));
  cogstart(&XBee, NULL, XBstack, sizeof(XBstack));

  while(1)
  {
    print("#");
    getBuff = getStr(inBuff,40);
    if(!strcmp(getBuff,"quit")) break;
    else
    {
      print("Invalid Command!\n");
    }   
  }
  return 0;  
}

/******************************************************************************/
/* Start access to XBee in its own cog. */
void XBee(void *par)
{
  int XBee;
  char inBuff[40];
  char getBuff;
  XBee = fdserial_open(21, 22, 0, 9600);
  while(1)
  {
    writeLine(XBee,">");
    getBuff = readStr(XBee,inBuff,40);
    if(!strcmp(getBuff,"quit")) break;
    else
    {
      writeLine(XBee,"Invalid Command!");
    }

//    pause(2000);  
  }
  writeLine(XBee,"Program Stop!n"); 
}

/******************************************************************************/
/* Start LED on/off in its own cog. */
void LedNF(void *par)
{
  while(1)
  {
    high(23);
    pause(500);
    low(23);
    pause(500);
  }
}
/******************************************************************************/

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-08-25 08:16
    Parallax should review and answer your questions. Meanwhile here are my answers.

    The Learn Simple Library functions are not named with ANSI-C library names, so there is no issue. All syntax is ANSI-C according to the C99 standard.

    Parallax didn't want to add the cost of XMM chips to the high volume Learn products like the Activity-board. They wanted a product that would fit entirely in the Propeller HUB RAM. Simple Libraries provide that ability. Users that want XMM can use the Propeller Memory Card (PMC.cfg driver to be added to the release).

    If you don't want the CR, use writeStr instead of writeLine.

    Simple View New Project does not make a folder by request of Parallax. Project View New Project does make a folder.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-08-25 10:34
    Users that want XMM can use the Propeller Memory Card (PMC.cfg driver to be added to the release).
    Actually I was making reference to the ability to use cogstart() with XMM mode. In my example program it would be nice to use the cogstart() with all memory modes(LMM,CMM,XMM). I keep harping on that because I think that it makes a big difference when you can use the cogs in all memory modes, in a relative easy to understand manner.

    After reading the descriptions for the simpletext.h functions, again, now I see where you do state the differences for the functions. I think that Parallax should reconsider the making of the folder in Simple View. What will they be zipping when they start to use the project zip command?

    Below is my example program with some changes that reflect the commands that do a built in CR.

    Ray
    /******************************************************************************/
    /*
    *  C3test2.c
    *
    * August 24, 2013
    *
    */
    #include "simpletools.h"
    #include "fdserial.h"
    
    /* XBee to run in its own cog, only works with LMM and CMM. */
    void XBee(void *par);
    unsigned int XBstack[40 + 25];
    /* Test run of another cog run, only works with LMM and CMM. */
    void LedNF(void *par);
    unsigned int Ledstack[40 + 25];
    
    /******************************************************************************/
    int main() 
    {
      // Add startup code here.
      char inBuff[40];
      int getBuff;
    
      pause(300);
      print("This is C3test2\n");
    
    /* Start the cogs. */
      cogstart(&LedNF, NULL, Ledstack, sizeof(Ledstack));
      cogstart(&XBee, NULL, XBstack, sizeof(XBstack));
    
      while(1)
      {
        putChar('#');
        getBuff = getStr(inBuff,40);
        if(!strcmp(getBuff,"quit")) break;
        else
        {
          putLine("Invalid Command!");  '' Auto CR
        }   
      }
      return 0;  
    }
    
    /******************************************************************************/
    /* Start access to XBee in its own cog. */
    void XBee(void *par)
    {
      int XBee;
      char inBuff[40];
      char getBuff;
      XBee = fdserial_open(21, 22, 0, 9600);
      while(1)
      {
        writeStr(XBee,">");  // No auto CR
        getBuff = readStr(XBee,inBuff,40);
        if(!strcmp(getBuff,"quit")) break;
        else
        {
          writeStr(XBee,"Invalid Command!");  // No auto CR
        }
    
    //    pause(2000);  
      }
      writeLine(XBee,"Program Stop!"); 
    }
    
    /******************************************************************************/
    /* Start LED on/off in its own cog. */
    void LedNF(void *par)
    {
      while(1)
      {
        high(23);
        pause(500);
        low(23);
        pause(500);
      }
    }
    /******************************************************************************/
    
    
  • jazzedjazzed Posts: 11,803
    edited 2013-08-25 10:53
    Rsadeika wrote: »
    Actually I was making reference to the ability to use cogstart() with XMM mode. In my example program it would be nice to use the cogstart() with all memory modes(LMM,CMM,XMM). I keep harping on that because I think that it makes a big difference when you can use the cogs in all memory modes, in a relative easy to understand manner.

    That is a work in progress - we have discussed it often. The earliest it can be done is with the Propeller2 release.

    Like Project View, Simple View Zips whatever is in the project + whatever is found in the libraries.

    I have no control over the folder decision.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-08-25 17:12
    Rsadeika wrote: »
    Actually I was making reference to the ability to use cogstart() with XMM mode. In my example program it would be nice to use the cogstart() with all memory modes(LMM,CMM,XMM). I keep harping on that because I think that it makes a big difference when you can use the cogs in all memory modes, in a relative easy to understand manner.
    We are working on this as Steve said in another message. However, using XMM in multiple COGs at the same time will come at a cost. Each COG that is running XMM code will require a separate cache and that will take up hub memory. Currently, the single XMM COG uses 8k of hub memory for a cache. Smaller caches are possible of course but with reduced performance.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-08-26 03:31
    However, using XMM in multiple COGs at the same time will come at a cost.
    Once you move away from Spin/PASM for the Propeller, everything else comes with a performance cost to the Propeller. For some programs, maybe XMM in multiple COGs is something a programmer can live with, as long as it is there to try and compare. Has anybody developed a small chart describing the benefits and deficits of the different memory modes when used with multiple COGs?

    I was looking for a keyboard driver in C, but I could not find one. I thought, at one time there was a C keyboard driver in the OBEX, but I did not find it. It would be nice to find a combined VGA and keyboard driver, or at least I think it would be nice. I would still like to try that with the C3 board, just too see what it would look like. I am still looking into ways of making that C3 or Demo Board(if I ever find it) into a stand-alone/wireless system.

    Ray
  • jazzedjazzed Posts: 11,803
    edited 2013-08-26 07:34
    Rsadeika wrote: »
    Once you move away from Spin/PASM for the Propeller, everything else comes with a performance cost to the Propeller.

    Here's an interesting example of performance cost for you: Spin Simple_Serial.spin -vs- Propeller-C simpletext default serial library. Both are half-duplex serial port driver that do not require an extra COG. Simple_Serial.spin maximum standard speed is 19200 bps while simpletext serial maximum standard speed is 115200 bps. To achieve 115200 bps in Spin/PASM with P1, it is necessary to waste a COG.
    Rsadeika wrote: »
    I was looking for a keyboard driver in C, but I could not find one.

    I've spent some time making Keyboard and VGA Simple Libraries for simpletext. It will be published some time after labor day.
  • RsadeikaRsadeika Posts: 3,837
    edited 2013-08-26 12:44
    Below is a slightly updated program, but the question I have is - why all the warnings, and what would be the correct way of using the function that would not give a warning?

    Ray
    Project Directory: E:/PropGCC/programs/C3test/C3test2/
    
    propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2090)
    propeller-elf-gcc.exe -I . -L . -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libfdserial -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libfdserial/cmm/ -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/cmm/ -I C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -o cmm/C3test2.elf -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 C3test2.c -lm -lfdserial -lm -lfdserial -lsimpletools -lsimpletext -lsimplei2c -lm -lfdserial -lm -lfdserial -lsimpletools -lsimpletext -lm -lfdserial -lm -lfdserial -lsimpletools -lm -lfdserial -lm -lfdserial -lm -lfdserial -lm -lm -lfdserial -lm
    C3test2.c: In function 'main':
    C3test2.c:36:13: warning: assignment makes integer from pointer without a cast [enabled by default]
    C3test2.c:37:5: warning: passing argument 1 of 'strcmp' makes pointer from integer without a cast [enabled by default]
    c:\program files (x86)\simpleide\propeller-gcc\bin\../lib/gcc/propeller-elf/4.6.1/../../../../propeller-elf/include/string.h:20:8: note: expected 'const char *' but argument is of type 'int'
    C3test2.c: In function 'XBee':
    C3test2.c:57:8: warning: assignment makes integer from pointer without a cast [enabled by default]
    C3test2.c:59:3: warning: passing argument 1 of 'writeLine' makes pointer from integer without a cast [enabled by default]
    C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/simpletext.h:323:6: note: expected 'struct text_t *' but argument is of type 'int'
    C3test2.c:62:5: warning: passing argument 1 of 'writeStr' makes pointer from integer without a cast [enabled by default]
    C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/simpletext.h:329:6: note: expected 'struct text_t *' but argument is of type 'int'
    C3test2.c:63:5: warning: passing argument 1 of 'readStr' makes pointer from integer without a cast [enabled by default]
    C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/simpletext.h:257:7: note: expected 'struct text_t *' but argument is of type 'int'
    C3test2.c:67:7: warning: passing argument 1 of 'writeLine' makes pointer from integer without a cast [enabled by default]
    C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/simpletext.h:323:6: note: expected 'struct text_t *' but argument is of type 'int'
    C3test2.c:71:7: warning: passing argument 1 of 'writeLine' makes pointer from integer without a cast [enabled by default]
    C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/simpletext.h:323:6: note: expected 'struct text_t *' but argument is of type 'int'
    C3test2.c:76:3: warning: passing argument 1 of 'writeLine' makes pointer from integer without a cast [enabled by default]
    C:/Users/Ray/Documents/SimpleIDE/Learn/Simple Libraries/Text Devices/libsimpletext/simpletext.h:323:6: note: expected 'struct text_t *' but argument is of type 'int'
    propeller-load -s cmm/C3test2.elf
    propeller-elf-objdump -h cmm/C3test2.elf
    Done. Build Succeeded!
    
    propeller-load.exe -Dreset=dtr -I C:/Program Files (x86)/SimpleIDE/bin/../propeller-gcc/propeller-load/ -b C3 cmm/C3test2.elf -r -p COM10
    Propeller Version 1 on COM10
    Loading cmm/C3test2.elf to hub memory
    
    8784 bytes sent
    
    Verifying RAM ... 
    OK
    

    /******************************************************************************/
    /*
    *  C3test2.c
    *
    * August 24, 2013
    *
    */
    #include "simpletools.h"
    #include "fdserial.h"
    
    /* XBee to run in its own cog, only works with LMM and CMM. */
    void XBee(void *par);
    unsigned int XBstack[40 + 25];
    /* Test run of another cog run, only works with LMM and CMM. */
    void LedNF(void *par);
    unsigned int Ledstack[40 + 25];
    
    /******************************************************************************/
    int main() 
    {
      // Add startup code here.
      char inBuff[40];
      int getBuff;
      int ledCog, xbCog;
    
      pause(300);
      print("This is C3test2\n");
    
    /* Start the cogs. */
      ledCog = cogstart(&LedNF, NULL, Ledstack, sizeof(Ledstack));
      xbCog = cogstart(&XBee, NULL, XBstack, sizeof(XBstack));
    
      while(1)
      {
        putChar('#');
        getBuff = getStr(inBuff,40);
        if(!strcmp(getBuff,"quit")) break;
        else
        {
          putLine("Invalid Command!");  // Auto CR
        }   
      }
      putLine("Program Stopped!");
      cogstop(ledCog);
      cogstop(xbCog);  
      return 0;  
    }
    
    /******************************************************************************/
    /* Start access to XBee in its own cog. */
    void XBee(void *par)
    {
      int XBee;
      char inBuff[40];
    
    /*                     Rx  Tx  Mode Baud */
      XBee = fdserial_open(21, 22, 0, 9600);
      pause(250);
      writeLine(XBee,"This is C3base wireless."); // Auto CR
      while(1)
      {
        writeStr(XBee,">");  // No auto CR
        readStr(XBee,inBuff,40);
        if(!strcmp(inBuff,"quit")) break;
        else if(!strcmp(inBuff,"menu"))
        {
          writeLine(XBee,"xbMenu - menu, quit, ");
        }
        else
        {
          writeLine(XBee,"Invalid Command!");  // Auto CR
        }
    
    //    pause(2000);  
      }
      writeLine(XBee,"Program Stop!"); // Auto CR
    }
    
    /******************************************************************************/
    /* Start LED on/off in its own cog. */
    void LedNF(void *par)
    {
      while(1)
      {
        high(23);
        pause(500);
        low(23);
        pause(500);
      }
    }
    /******************************************************************************/
    
    
  • jazzedjazzed Posts: 11,803
    edited 2013-08-26 13:05
    High level link to Simple Library documentation.
    https://propsideworkspace.googlecode.com/hg/Learn/Simple%20Libraries%20Index.html

    Link to fdserial library documentation.
    https://propsideworkspace.googlecode.com/hg/Learn/Simple%20Libraries/Text%20Devices/libfdserial/Documentation%20fdserial%20Library.html

    Link to fdserial_open documentation.
    https://propsideworkspace.googlecode.com/hg/Learn/Simple%20Libraries/Text%20Devices/libfdserial/html/fdserial_8h.html#a43ff539c64dfbb0f2f95403a4c746788

    There you see that fdserial_open returns an fdserial pointer rather than an int.
    You have defined XBee as an int rather than fdserial. The compiler says you have made a mistake.
    The type fdserial is another name for the struct text_t. It is common to use such typedefs in C.

    C is a heavily typed language that allows such mistakes to be caught at compile time rather than run time.
Sign In or Register to comment.