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

SimpleIDE and the C3 board

I started messing around with my C3 board, and in the Board Type selection, using SimpleIDE, there is a choice of C3 and C3F. What is the difference? Since the C3 board has Flash RAM(1MB) and SPI RAM(2x32K), is there some way to use all external RAM, using PropGCC, that is?

Ray

Comments

  • The C3 driver supports both Flash and RAM whereas the C3F driver supports only Flash. The drivers implement an 8K cache in hub RAM, which is used entirely for Flash with C3F. However, with C3 board type the 8K cache is divided into two 4K chunks that are used to support Flash and RAM. This enables C3F to run faster than C3 for programs that use the XMMC model. If the XMM model is needed for RAM access the C3 board type must be used.
  • Thanks Dave, I am still not sure which is the best one to use. I tried both with the XMMC..., and they both seem to work.

    Since I am restarting my project using the iRobot Create, with the C3 being the control, I would like to use the ADC setup on the C3. The Create battery puts out ~14VDC, when charged up, and I know I have to use a voltage divider setup to knock down the voltage to 5V, for the ADC, does anybody have any info on a easier solution for the voltage divider setup? Would be nice if there was a pre made PC board with a two wire connector from the battery and two wires for the ADC, and then magic in between to produce the necessary 5V.

    Ray
  • So, I found this device on ebay ,http://www.ebay.com/itm/ArduPilot-PX4-3DR-APM-Arduino-Voltage-Detection-Sensor-Module-Voltage-Divider-/301981579328?hash=item464f813840:g:YPoAAOSwMHdXRgSw, although it states that it is for an Arduino, I think that it should work with the C3. The only reason that I am looking at this particular seller, it is in my area, so it should take less than a week to get to my front door.

    Since there is a lib in SimpleIDE to work with ADC, I think that this should be a straight forward hookup and usage. At least it was that way when I used it with the lib for the Activity board ADC.

    But, it is a device from China, wondering how long before I have parts failure? Anybody see any potential problems that I could run into with this device?

    Ray
  • Just to verify again, SimpleIDE Version 1.0.2(RC2) for Windows, using the C3 board and using any version of XMM, you can not start up any additional COGs. So, if you want to use the available external RAM, your program will have to be monolithic.

    I only mention this because I noticed that all the C3 boards are sold out, so if their are some new users wanting to use all COGs and external RAM, you can not, at least not with latest official SimpleIDE.

    Ray
  • I am more a SPIN/PASM guy but I also try(ed) C/C++ on the Prop.

    What you state in the above post is not entirely true.

    Yes, you can just use XMM with one COG but you can still run other COGS in parallel just not with XMM.

    So your main(XMM) program can without problem start other COGs running PASM or C written stuff.

    Just the extended memory access is bound to one COG/process.

    Correct me if I am wrong, but this is my current understanding.

    Enjoy!

    Mike
  • What you state in the above post is not entirely true.

    Yes, you can just use XMM with one COG but you can still run other COGS in parallel just not with XMM.

    So your main(XMM) program can without problem start other COGs running PASM or C written stuff.

    Just the extended memory access is bound to one COG/process.

    Correct me if I am wrong, but this is my current understanding.
    Interesting, do you have some sample code that would highlight what you are suggesting? Now, you are within the SimpleIDE constraints.

    Messing around with the XMM mode(s), I noticed that the compiler does not give you any warnings, or at the very least, an error when you try to start another COG while in the XMM mode. So, if your command structure is cog_run(xxxx,128), and you have designated the functions, the program starts, but it does not run the function that has been COGed. This scenario turns out to be a major head scratching event, trying to find out why the COGed function is not cooperating.

    Now, for the running of PASM while using SimpleIDE, I am not aware of inline PASM being available in the official SimpleIDE release. Or for that matter what memory model you would use to be able to achieve the segmented memory usage design(parallel suggestion).

    Ray
  • David BetzDavid Betz Posts: 14,516
    edited 2016-11-14 11:47
    Rsadeika wrote: »
    Messing around with the XMM mode(s), I noticed that the compiler does not give you any warnings, or at the very least, an error when you try to start another COG while in the XMM mode. So, if your command structure is cog_run(xxxx,128), and you have designated the functions, the program starts, but it does not run the function that has been COGed. This scenario turns out to be a major head scratching event, trying to find out why the COGed function is not cooperating.

    This has been fixed for probably several years but the version of PropGCC that comes with SimpleIDE has never been updated to include the fixes.

  • Since the official SijmpleIDE does not support COGs when using XMM, I think PropGCC does support threads, even in the official SimpleIDE version. I am also assuming that they will work when you are using XMM.

    What I would like to do is somehow use threads to do pseudo-COGs? Hopefully some of the experts here will join in and comment on how and if it can be done.

    As a basic outline, what I have is a Create that will have an IR demodulator, for controlling the Create with a remote. A couple of Ping sensors, front and back. Plus an XBee module for communication, as a starter configuration. Oh, almost for about the onboard sht11 module.

    Under normal circumstances, I would just assign each of the devices to its own COG and use global variables for intra COGs data movement. So, how would I simulate the same condition using threads? Any ideas? Anyone?

    Ray
  • RsadeikaRsadeika Posts: 3,837
    edited 2016-11-20 16:32
    The program below is the only example that I have found to use threads(pthreads). Not sure if I understand the following:
    -That is programs can run more than 8 threads on propeller
    although at the cost of lost determinism and lost preemption.

    -since threads are non-preemtive multi tasked and requires the
    the programmer to understand yielding to other threads.
    With the above drawbacks, is their a way of simulating COGs? I was always under the impression that threads were very very similar to COGs, in the way that they work, otherwise it seems that threads, as used with PropGCC, are just some very fancy looping condition.

    Ray
    
    
    
    /**
     * @file toggle.c
     * This program demonstrates starting threads to
     * toggle pins, using the pthreads interface
     * The cog makes all IO except 30/31 toggle.
     *
     * Pthreads allow full Symmetric Multi Processing on propeller.
     * That is programs can run more than 8 threads on propeller
     * although at the cost of lost determinism and lost preemption. 
     *
     * Pthreads programs should not use waitcnt or simple_printf.
     * The subject can be difficult for beginning programmers since
     * threads are non-preemtive multi tasked and requires the
     * the programmer to understand yielding to other threads.
     *
     * All of these drawbacks can be avoided on Propeller because
     * of it's architecture using other programming techniques found
     * in the other toggle demos.
     *
     * Copyright (c) 2011 Parallax, Inc.
     * MIT Licensed (see at end of file for exact terms)
     */
    
    #include <stdio.h>
    #include <propeller.h>
    #include <pthread.h>
    #include <unistd.h>
    
    /*
     * here's the toggle code that runs in another cog
     */
    
    void *
    do_toggle(void *arg)
    {
      unsigned int pins = (unsigned int)arg;
    
      /* pin the thread to this particular cog
         this is necessary because we rely on the 
         DIRA hardware register, which is per cog
         pthread_set_affinity_thiscog_np is non-portable
         (hence the _np suffix) and is a Propeller
         extension
      */
      pthread_set_affinity_thiscog_np();
    
      /* nobody will be waiting for us to finish */
      pthread_detach(pthread_self());
    
      /* set up the hardware registers */
      _DIRA |= pins;
      _OUTA |= pins;
    
      for(;;) {
        _OUTA ^= pins; /* update the pins */
        printf("toggled %x on cog %d\n", pins, __builtin_propeller_cogid());
        sleep(1);      /* nap for 1 second */
      }
    }
    
    /*
     * main code
     * This is the main thread
     * It launches othre threads to actually toggle
     * the pins (one thread per pin).
     */
    
    pthread_t thr[32];
    
    int main (int argc,  char* argv[])
    {
        int i;
        unsigned int pins;
    
        printf("hello, world!\n");
    
        for (i = 0; i < 30; i++) {
          /* set up the parameters for the C cog */
          pins = (1U<<i);
    
          pthread_create(&thr[i], NULL, do_toggle, (void *)pins);
        }
        printf("done launching threads!\n");
        for(;;) {
          sleep(30);
        }
        return 0;
    }
    
    /* +--------------------------------------------------------------------
     *   TERMS OF USE: MIT License
     * +--------------------------------------------------------------------
     * Permission is hereby granted, free of charge, to any person obtaining
     * a copy of this software and associated documentation files
     * (the "Software"), to deal in the Software without restriction,
     * including without limitation the rights to use, copy, modify, merge,
     * publish, distribute, sublicense, and/or sell copies of the Software,
     * and to permit persons to whom the Software is furnished to do so,
     * subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be
     * included in all copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
     * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     * +--------------------------------------------------------------------
     */
    
    
Sign In or Register to comment.