GCC code is not working on my prop

So, recently I have bought P8X32A DIP40. I wired it on my soldering breadboard with ATMEL 24C256 and use CP2102 module for uploading. The blink programm written on PASM or Spin works without problems. But for some really unclear reason GCC code is not working. I mean, PROPGCC compiles it without any problems and loader loads it without any problems to EEPROM and RAM. But after it did it - nothing happens. I tried to convert Spin code to C and load it - no effect.

PS. I tryed it with SimpleIDE (Ubuntu 16.04 LTS). And also on other Linux machine with compiled from source propeller-gcc.

«1

Comments

  • 44 Comments sorted by Date Added Votes
  • I think you have to show us the C code you are trying to run. Else we have no idea what the problem could be.

    For sure prop-gcc does work.
  • Do you have a Crystal connected? If not, you might need to change some settings.
  • ShizuShizu Posts: 16
    edited December 2017 Vote Up0Vote Down
    One thing I have not mentioned in OP - I am using xtal oscillator 8MHz connected to pin 30-31. It looks like it soldered without problems. And when I configure in PropellerIDE clock settings and freq it works fine.

    Copied from gcc documetation:
    #include <stdio.h>
    #include <stdlib.h>
    #include <propeller.h>
    
    volatile unsigned int wait_time;
    
    /*
     * toggle thread function gets started in a CMM or LMM COG.
     * param arg = pin number to toggle
     */
    void do_toggle(void *arg)
    {
        int pin = (int) arg;
        unsigned int nextcnt;
        DIRA |= (1 << pin);         // set pin to output
        nextcnt = wait_time + CNT;
        for(;;) {
            OUTA |=  (1 << pin);    // set pin high
            nextcnt = waitcnt2(nextcnt, wait_time);
            OUTA &= ~(1 << pin);    // set pin low
            nextcnt = waitcnt2(nextcnt, wait_time);
        }
        cogstop(cogid());
    }
    
    void main (void)
    {
        int pin = 16;
        int stacksize = sizeof(_thread_state_t)+sizeof(int)*25;
        int *stack = (int*) malloc(stacksize);
        int cog;
        // initialize wait time to 50ms
        wait_time = CLKFREQ/20;
        // start the cog
        cog = cogstart(do_toggle, (void*) pin, stack, stacksize);
        printf("do_toggle started on COG %d\n", cog);
    }
    

    Another really simple one:
    #include <propeller.h>
    
    int main()
    {
      DIRA |= (1 << P0); 
      while (1)
      {
        OUTA |= (1 << P0);
        waitcnt(CLKFREQ/2+CNT);
        OUTA &= ~(1 << P0);
        waitcnt(CLKFREQ/2+CNT);
      }
    }
    

    This is Makefile for non-IDE project:
    PROPGCC=/opt/parallax
    CC=${PROPGCC}/bin/propeller-elf-gcc  
    LOAD=${PROPGCC}/bin/propeller-load  
    CFLAGS=-Os -mlmm -m32bit-doubles  -fno-exceptions  
    BOARD=GENERIC  
    PORT=/dev/ttyUSB0
    
    .PHONY: all clean load
    
    all: main
    
    clean:  
    	rm main *.o
    
    load: main  
    	${LOAD}  -p ${PORT} -I ${PROPGCC}/propeller-load -r -e  -D=xtal1pll8x $<
    

    In SimpleIDE I also added switch -D=xtal1pll8x in compiller options and run simple
    include "simpletools.h"
    int main()
    {
      while (1)
      {
         high(my_pin);
         pause(100);
         low(my_pin);
         pause(100);
      }
    }
    
  • mikeologistmikeologist Posts: 234
    edited December 2017 Vote Up0Vote Down
    Your clock is on physical pins 30-31, not the logical pins 30-31? I assume yes if you got anything to load.
    And when I configure in PropellerIDE clock settings and freq it works fine
    How do you set your clock frequency with an 8Mhz clock?
    Any com port in a storm.
    Floating point numbers will be our downfall; count on it.
    Imagine a world without hypothetical situations.
  • Actually, mikeologist, the Prop starts up using it's internal R/C oscillator. You don't need any external clock to get a Prop to run. The loader works without and external clock. So wiring the clock wrongly would not show until your code does not run.
  • Just an observation:
    The first example you posted compiles and runs fine from SimpleIDE (I changed the pin value to 26 for an Activity Board). The blink is a bit fast though.

    The second example does not compile: P0 is undefined. Once defined it runs fine (P0 = 26 for an activity board)

    The second example does not compile; Missing '#' before 'include' and 'my_pin' is undefined. It runs fine when these are corrected.

    To clarify, you are running this from a Linux systems (or VM) and not something like a Raspberry Pi, correct?

    Do you have an diagram of the circuit you are using?
  • Shizu,

    Do you have anything besides that CP2102 such as an FTDI chip-based module?

    Are you using that latest version with the latest library?
    If I recall I think SimpleIDE defaults to the Activity board.
  • ShizuShizu Posts: 16
    edited December 2017 Vote Up0Vote Down
    JonM,
    I think schematic will look like:
    PropellerConnection.png

    I was making breadboard exactly how it looks on schematic (I guess, you dont want be bothered by trying figure out what can be wrong on wired soldering board).
    But as I mentioned before, I am using AT24C256 (seems it is the same IC). Instead of prop plug or FTDI, i am using CP2102 (As you see, it it worked without problems when uploading with PropellerIDE, and no error messages when I was uploading with SimpleIDE) DTR pin of CP2102 connected to RES pin of P8X32A. And I am using 8 MHz crystal. But as it was said in upper posts, P8X32A starts with its own RC-oscillator and should work without problems.

    gcc version 4.6.1 (propellergcc_v1_0_0_2411)

    mikeologist,
    I can open Memory Map in PropellerIDE, and there I can set mode and frequency settings for my configuration.

    It is really weird. Maybe I have something wrong with propeller mode options (mcog, mlmm, etc). Or I should put EEPROM IC out of socket, and make dump of it contents. Maybe I have to try FTDI module. Maybe I have to try put out of socket P8X32A and try uploading to RAM without any additional connections. Maybe I have to try to load from Windows (I not believe Linux machine (not virtual) can make problems in this situation, though I have to try it also)




  • PublisonPublison Posts: 9,873
    edited December 2017 Vote Up0Vote Down
    With an 8 Mhz Xtal, your PLL should be x10 x8 to yield 80 64 mhz CPU.
    Infernal Machine
  • Publison wrote: »
    With an 8 Mhz Xtal, your PLL should be x10 to yield 80 mhz CPU.
    There is no such multiplier so you MUST use PLLx8 and NOT PLLx16 !!!
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Shizu wrote: »
    JonM,
    I think schematic will look like:
    PropellerConnection.png

    I was making breadboard exactly how it looks on schematic (I guess, you dont want be bothered by trying figure out what can be wrong on wired soldering board).
    But as I mentioned before, I am using AT24C256 (seems it is the same IC). Instead of prop plug or FTDI, i am using CP2102 (As you see, it it worked without problems when uploading with PropellerIDE, and no error messages when I was uploading with SimpleIDE) DTR pin of CP2102 connected to RES pin of P8X32A. And I am using 8 MHz crystal. But as it was said in upper posts, P8X32A starts with its own RC-oscillator and should work without problems.

    gcc version 4.6.1 (propellergcc_v1_0_0_2411)

    mikeologist,
    I can open Memory Map in PropellerIDE, and there I can set mode and frequency settings for my configuration.

    It is really weird. Maybe I have something wrong with propeller mode options (mcog, mlmm, etc). Or I should put EEPROM IC out of socket, and make dump of it contents. Maybe I have to try FTDI module. Maybe I have to try put out of socket P8X32A and try uploading to RAM without any additional connections. Maybe I have to try to load from Windows (I not believe Linux machine (not virtual) can make problems in this situation, though I have to try it also)



    The PROPPLUG has a transistor reset circuit from DTR to RESET. This does not exist on the CP2102 boards, so you will need to duplicate the transistor reset circuit if you want to reliably use the CP2102. You can use any generic NPN transistor.

    Be careful of the transistor pinouts - a 2N2222 has different pinouts between manufacturers - a PN2222 is often called a 2N2222 but has different pinouts to the normal 2N2222.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • I've downloaded a PropGCC version for Mac from the following and unpacked it:
    propellergcc_v1_0_0_2131-x86_64-macosx.tar.bz2
    https://code.google.com/archive/p/propgcc/downloads

    Using the command line example from the following.
    https://sites.google.com/site/propellergcc/downloads

    I changed the blinkcogs example so it would blink LED 26 on a Propeller and then compiled it:
    BlinkCogs jonnymo$ ~/Documents/SimpleIDE/parallax/bin/propeller-elf-gcc-4.6.1 -o blinkcogs blinkcogs.c
    


    Then using 'propeller-load' from the PropellerGCC package, loaded the code on an Activity Board
    BlinkCogs jonnymo$ ~/Documents/SimpleIDE/parallax/bin/propeller-load -e blinkcogs
    

    This loaded without issue, however it did not run. I had to reset the board (PWR switch set to 0 then back to 1) and the code started to run.
    Perhaps you need to reset your Propeller circuit to get it to run.

  • If you are exactly following the schematic, you must add some bypass caps between Vss and Vdd. As close as possible to the Prop pins.
    After all these years, it is difficult to believe Parallax has not fixed this schematic.

    And, of course, you ought to use a 5 MHz crystal at least until you better understand how to push the envelope.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Cluso99 wrote: »
    Publison wrote: »
    With an 8 Mhz Xtal, your PLL should be x10 to yield 80 mhz CPU.
    There is no such multiplier so you MUST use PLLx8 and NOT PLLx16 !!!
    Don't know what I was thinking. Post edited.
    Infernal Machine
  • ShizuShizu Posts: 16
    edited December 2017 Vote Up0Vote Down
    OK. Try to upload on your P8X32A my project. You might have to change a little bit Makefile. If it is working on your circuit without any issues, I maybe have to change or recheck certains parts of my circuit.
  • Code works just fine on my Flip Chip
    #include <stdio.h>
    #include <stdlib.h>
    #include <propeller.h>
    
    #define P0 26 /* Change to your pin*/
    
    
    
    int main()
    {
      
        DIRA |= (1 << P0);
        while (1)
        {
            OUTA |= (1 << P0);
            waitcnt(CLKFREQ/2+CNT);
            OUTA &= ~(1 << P0);
            waitcnt(CLKFREQ/2+CNT);
        }
    
    }
    

    produces a half second pulse on the LED

    This is using the compiler built into the IDE and not your make routine and on windows
    propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2408)
    propeller-elf-gcc.exe -I . -L . -o cmm/TestLED.elf -Os -mlmm -m32bit-doubles -fno-exceptions -std=c99 TestLED.c -lm
    propeller-load -s cmm/TestLED.elf
    propeller-elf-objdump -h cmm/TestLED.elf
    Done. Build Succeeded!
    
    proploader.exe -r -I C:/Program Files (x86)/SimpleIDE/bin/../propeller-gcc/propeller-load/ -b activityboard -p COM23 cmm/TestLED.elf
    
    Opening file 'cmm/TestLED.elf'Downloading file to port COM23
    2504 bytes sent                  
    

    Mike
  • Well... I am going to think more about this, and take some dive into PASM or Spin... I'd like there was some sort of debugging interface like JTAG inside MCU. I have no idea what happens inside it after I upload code. In theory object code I compiled of my C-code will be loaded into its RAM and started to be executed by cogs directly (without interpreter). For more reliable circuit I have to add cap with transistor in DTR line (or buy FTDI chip, though it costs bit more expensive than cp2102) and bypass caps (but this is rather experimental board, no so critacal).
  • JonMJonM Posts: 291
    edited December 2017 Vote Up0Vote Down
    Shizu wrote: »
    OK. Try to upload on your P8X32A my project. You might have to change a little bit Makefile. If it is working on your circuit without any issues, I maybe have to change or recheck certains parts of my circuit.

    I made some changes to your make file and main.c.
    In your Makefile you were running the load command twice. Also, the ">&" was not liked by the shell. I added a "OUT_EXE = main" just to ensure 'main' was being loaded.
    Also, ensure you are using the proper TTY instance for your Prop.

    Try this:
    PROPGCC=/opt/parallax
    CC=${PROPGCC}/bin/propeller-elf-gcc  
    LOAD=${PROPGCC}/bin/propeller-load  
    CFLAGS=-Os -mlmm -m32bit-doubles  -fno-exceptions  
    BOARD=QUICKSTART 
    PORT=/dev/ttyUSB0
    OUT_EXE = main
    .PHONY: all clean load
    
    all: main
    
    clean:  
    	rm main *.o
    
    load: main  
    	${LOAD}  -I -r -e ${OUT_EXE} -p ${PORT}  2>&1
    


    Although your 'main.c' may work as written, to be clearer you might want to change the 'DIRA' statement to:
    DIRA |= (1 << P0);
    

    That is considering your LED is on pin 0.


    This is what I see when running the Makefile with the changes I suggested against an Activity Board. NOTE: I did change the PORT and PROPGCC location for my environment.
    gcc_project jonnymo$ make load
    /Users/jonnymo/Documents/SimpleIDE/parallax/bin/propeller-load   -I -r -e main -p /dev/cu.usbserial-DAWTKWXB 2>&1
    Propeller Version 1 on /dev/cu.usbserial-DAWTKWXB
    Loading main to EEPROM via hub memory
    2532 bytes sent                  
    Verifying RAM ... OK
    Programming EEPROM ... OK
    Verifying EEPROM ... OK
    


    Again, after loading, I had to power cycle the board to get the code to run.

    I hope this helps.
  • Shizu,

    The Propeller chip works since you can download Spin and PASM to it so it's your C code or GCC that's the culprit.
    What version are you using?

    Have you also tried from another computer?
  • ShizuShizu Posts: 16
    edited December 2017 Vote Up0Vote Down
    Today I was trying to load C-code from Windows 7 and got build error with code -1. I installed SimpleIDE and drivers, and reboot for sure, but after reboot I still get error -1 when loading. Maybe something wrong with permissions and drivers, I see the signal LEDs of module do not flashes.

    JonM,
    No effect.

    Genetix,
    gcc version 4.6.1 (propellergcc_v1_0_0_2411) compiled from source
    SimpleIDE picked up from downloads section from parallax site.

  • Did you add the transistor reset circuit?
    It's my bet that the downloaded is failing due to the reset circuit being wrongly implemented.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • ShizuShizu Posts: 16
    edited December 2017 Vote Up0Vote Down
    No I haven't transistor circuit. Well, going to solder it.
    Should I solder how it looks on this schematic? propstick-schematic.jpg
  • GenetixGenetix Posts: 1,098
    edited December 2017 Vote Up0Vote Down
    Shizu,

    Every now and then I need to download a program a 2nd time using Windows 7 and I have used both the QuickStart and Activity boards with SimpleIDE without trouble.
    Both of those boards have on-board FTDI USB-to-Serial chips.
    Windows is sometimes quirky with USB.
    Is your Windows user account an Administrator?

    Unfortunately none of those schematic show 0.1 uF (marked 104) decoupling capacitors across the power pins (Vdd to Vss).
    Look at page 38 of the PE Kit text and note the 2 yellow capacitors that go from Vdd (3.3V) to Vss (GND) on each side of the Propeller chip.
    https://www.parallax.com/sites/default/files/downloads/122-32305-PE-Kit-Labs-Fundamentals-Text-v1.2.pdf
    If I recall not having these capacitors could cause the PLL (clock frequency multiplier) to burn out.
  • Yes, just use the transistor schematic... 1 x 10nF, 1 x 10K, 1 x NPN transistor

    There are likely to be reset problems without using this circuit. The more resets required during loading (I believe GCC loaders do this for a multilevel download) the more likely the failure. Its both timing and polarity sensitive, and is OS dependant too. Just like the problems you are describing.

    Make sure both power pins are tied together, and both ground pins are tied together (4 pins on a QFP). Not connecting any of these will likely result in a PLL failure in the chip (will not work in crystal mode)!!! If that is not directly, you will need bypass capacitors on both sides of the DIP package. You should also have 10uF (tantalum preferred) across the pins supplying them, expecially if there is some distance from the 3V3 regulator.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • GenetixGenetix Posts: 1,098
    edited December 2017 Vote Up0Vote Down
    Speaking of Reset, shouldn't the RESn (Active-low Reset) pin be pulled up to Vdd through a resistor like 10K?
  • Shizu wrote: »
    Today I was trying to load C-code from Windows 7 and got build error with code -1. I installed SimpleIDE and drivers, and reboot for sure, but after reboot I still get error -1 when loading. Maybe something wrong with permissions and drivers, I see the signal LEDs of module do not flashes.

    Could you provide the error message that you are seeing from the SimpleIDE Build Status window?

    Does Device Manager show your USB device?
    Considering your are using a CP2102 on your board, you may need to install a separate Driver outside of what Parallax provides with SimpleIDE
    https://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/where-can-i-download-drivers-for-cp2102-usb-to/e971a3e1-d037-4ed3-9fa6-2f4a27eae0c0?auth=1

    To understand from the initial issue, you are able to load both PASM or SPIN (I'm assuming using PropellerIDE) code to the Propeller circuit without issue, correct? Also, it looks like you were able to load the code from the SimpleIDE on Linux. Did it run?

    You may want to check your code considering much of what you have posted has had issues and did not compile or run as posted.
    I did notice that in some of the examples you posted you show a PIN value of 16 for the Blinky LED and others PIN 0. What pin is your Blinky LED connected to? Is it possible that you are running your code against the wrong pin number for where the LED is connected?
    Just a suggestion.

  • ShizuShizu Posts: 16
    edited December 2017 Vote Up0Vote Down
    Ehh, I little confused about DTR. In datasheet I see DTR line is conected with PNP transitstor 2N3906 pulled to 3.3v with cap 0.1uF, and on picture upper 10nF and NPN pulled to GND. Is it not critical difference? Can I use intead of 10nF 0.1 uF, if i have't last one?

  • Genetix wrote: »
    Speaking of Reset, shouldn't the RESn (Active-low Reset) pin be pulled up to Vdd through a resistor like 10K?

    Nope, when BOEn is low, the prop pulls it up internally (through 5K)
  • ShizuShizu Posts: 16
    edited December 2017 Vote Up0Vote Down
    So... I studied a little bit upper schematic and came to thought that transistor and cap is not really necessary. This is used to decouple button reset and
    UART-module reset from short circuit. So if I am not using button in my circuit, and even I have no problems with uploading code it maybe no need Soldering it? Am I wrong? Anyway, it is good idea to put mcu out of socket and make transistor reset circuit on non-soldering breadboard. I will post result soon here.
  • Shizu wrote: »
    So... I studied a little bit upper schematic and came to thought that transistor and cap is not really necessary. This is used to decouple button reset and
    UART-module reset from short circuit. So if I am not using button in my circuit, and even I have no problems with uploading code it maybe no need Soldering it? Am I wrong? Anyway, it is good idea to put mcu out of socket and make transistor reset circuit on non-soldering breadboard. I will post result soon here.
    Wrong
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
Sign In or Register to comment.