Shop OBEX P1 Docs P2 Docs Learn Events
Autostart of a C program — Parallax Forums

Autostart of a C program

SparkoSparko Posts: 8
edited 2015-04-22 15:28 in Propeller 1
I have a working program written in C and saved to the EEPROM of a Propeller P8X32A . The program autostarts fine while powered up with a USB cable to the PC the program was written and compiled on. It also autostarts fine when powered by any PC with Simple IDE software and drivers installed.

The Propeller C based program will not start when powered up with an AC to USB power adapter. It will not start when powered by a PC that has not had Simple IDE and drivers installed.

Please tell me what I need to get the autostart working.

Below is the first part of the C program:

Thank you Sparko


#include "simpletools.h" // Library include

void blink(); // Forward declaration


volatile int reps = 0; // <-- add
volatile int buttonchange = 0;
volatile int pulses = 0;
volatile int poc1sel =0;
volatile int poc2sel =0;

int button1 = 0;
int button2 = 0;



int main() // Main function
{
cog_run(&blink, 120); // <-- change! // Run blink ...

while(1) // <-- add
{

print("poc1sel = %d\n", poc1sel);


............................

Comments

  • DavidZemonDavidZemon Posts: 2,973
    edited 2015-04-22 11:54
    That snippet of code looks okay. I think you're going to need to post your whole project (the zip option in SimpleIDE's menu).

    As a side note - you're using "print" instead of "printi". printi is an equivalent to print, but does not support floating point variables. You'll save a lot of code space by switching.
  • idbruceidbruce Posts: 6,197
    edited 2015-04-22 11:57
    Sparko

    This sounds more like a power related issue than a software related issue, but I could be wrong.

    The more information you provide, the better assistance you will receive.

    What type of board are you using and what type of power supply?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-04-22 12:31
    I think the problem is related to the hardware, not the software. The original post indicated using a P8X32A, so my assumption was a custom system. Now I am wondering if it is in fact a development board or one that uses the FTDI chip with power-switching circuitry. If that's the case the board may not work since the USB chip won't be enumerated and enable the power pin output when not connected to a USB host controller. The USB power adapter usually won't have that feature/functionality.
  • idbruceidbruce Posts: 6,197
    edited 2015-04-22 12:37
    I think the problem is related to the hardware, not the software. The original post indicated using a P8X32A, so my assumption was a custom system. Now I am wondering if it is in fact a development board or one that uses the FTDI chip with power-switching circuitry. If that's the case the board may not work since the USB chip won't be enumerated and enable the power pin output when not connected to a USB host controller. The USB power adapter usually won't have that feature/functionality.

    That sounds like a darn good diagnosis :)
  • SparkoSparko Posts: 8
    edited 2015-04-22 13:20
    Hi Chris Savage,

    Your assumption is correct, I am developing using the Multicore Development Board. When I purchased it I noted that it had an onboard EEPROM so I may have incorrectly assumed it would autostart the program.

    So my basic question is whether or not this board will autostart with a non-PC USB power supply or do I need another board to drop the code into?

    If I need a board that will autostart what would be the least expensive board that Parallax offers? I am hoping to produce quantities of these very trivial controllers so keeping the price down would be helpful.

    So far my C code is only about 100 lines. I need only 5 inputs and 8 outputs.

    I will proceed by testing with a PC along side the development board and machinery being controlled.

    Thank you very much

    Sparko




    Swindude - Thanks for the tip on printing. Printing was just in the code to be able to see how the program was reacting to the inputs. I would likely be removed in the final product.





    "I think the problem is related to the hardware, not the software. The original post indicated using a P8X32A, so my assumption was a custom system. Now I am wondering if it is in fact a development board or one that uses the FTDI chip with power-switching circuitry. If that's the case the board may not work since the USB chip won't be enumerated and enable the power pin output when not connected to a USB host controller. The USB power adapter usually won't have that feature/functionality"
  • Duane DegnDuane Degn Posts: 10,588
    edited 2015-04-22 14:05
    If this is a QuickStart Rev A board you need to ground the USB Power Enable pin. This should be pin # 30 on the QuickStart's header.

    This will allow the board to accept power through the USB connector without the need of communicating with the PC first.
  • SparkoSparko Posts: 8
    edited 2015-04-22 15:12
    Hi Duane,

    That's it. I tried what you suggested and it worked.

    Sure appreciated it. Since this morning I read the Propeller data sheet and from the two paragraphs below I suspected there was a way. You filled in the blank for me. (See section b. below.)

    Thanks a lot.

    Sparko




    2. The Boot Loader performs one or more of the
    following tasks, in order:
    a. Detects communication from a host, such as a
    PC, on pins P30 and P31. If communication
    from a host is detected, the Boot Loader
    converses with the host to identify the Propeller
    chip and possibly download a program into
    global RAM and optionally into an external 32
    KB EEPROM.
    b. If no host communication was detected, the Boot
    Loader looks for an external 32 KB EEPROM on
    pins P28 and P29. If an EEPROM is detected,
    the entire 32 KB data image is If an EEPROM is detected,
    the entire 32 KB data image is loaded into the
    Propeller chip’s global RAM.
  • SparkoSparko Posts: 8
    edited 2015-04-22 15:20
    Last question - How do I change this thread to "solved"?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2015-04-22 15:28
    I was at the dealer so I didn't get back to you right away, but I see Duane helped you. As I suspected you were using a board that couldn't be powered from that type of adapter without a little help. As for the thread if you edit your post and go to the advanced editor you can change the status, but I got it for you this time. =)
Sign In or Register to comment.