Main Site Documentation

Run code without Visual Studio


#1

Hi,

about 2 years ago I buyed a sweet Panda FEZ 2 for a hobby project.
Now I started my work and made the first steps. (Read manuals, installed software, updated the board firmware)

For my first test project I use Visual Studio 2012 and linked to the binaries of the 4.1 SDK.
My test application is a blinking LED code and works fine, when I start the code in Visual Studio (F5). But it only runs in this way.

When I push reset or plug off/in the board, the code doesn’t run anymore.

What is needed that the code runs independent of Visual Studio?
I didn’t find information about this in the beginners documents, nor by Google, nor here in the forums. (Maybe I used the wrong search keys?)

As I know from other microcontrollers, the code runs automatically when the board gets power.

I would be happy about some hints.


#2

Normaly your code should simply run after you reset or power up your board.
Could you please post your code you are using?


#3

What a quick answer (-:

Here is my code:



using System;
using System.Threading;
using GHIElectronics.NETMF;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.IO;
using GHIElectronics.NETMF.System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.IO;




namespace TEST_PANDA_MFConsoleApplication1
{
    public class Program
    {

        static OutputPort myLED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, false);


        public static void Main()
        {

            //Debug.Print("Hier ist Panda FEZ 2");
            for (Int16 i = 1;  i < 40;  i++)
            {
                //Debug.Print(".");
                System.Threading.Thread.Sleep(500);
                myLED.Write(!myLED.Read());
            }
        }

    }
}

#4

@ Beauty - With an embedded program, you should never exit main(). Try replacing your for statement with while(true).


#5

Putting a “while (true);” statement is playing with fire! Use “Thread.Sleep(-1);” at the end of function main().


#6

@ Simon from Vilnius - I thought we no longer need to put a “sleep forever” statement. Wasn’t it fixed so that Main thread would never exit?
I have not used that Sleep statement. I always use timer which starts once after Debug.Print(“Program Started”) is called. Never had any issues. Was I very very lucky?


#7

You are confusing it with gadgeteer. Main should always have a sleep in it.


#8

When I add a Sleep(-1) to the end, my problem isn’t solved.

Nethertheless, my application should blink the LED for about 20 seconds before it leaves the loop.
Starting during VS works fine, but not by an other way.


#9

Check the code. Nothing wrong with what I suggested.


#10

@ Gus - Yeah, you are right :wink: .


#11

This is a “known” situation.

https://www.ghielectronics.com/community/forum/topic?id=14284

Ever since what may have been the USB driver change to WinUSB, pausing debug will cause a Panda/USBizi based device to pause execution.

You can test this by connecting your device to power via a phone charger not your computer, and showing the code starts normally by blinking the lights.

The only way I can suggest you get around this is to connect tot he debugging information via MFDeploy - but that will be a couple of extra steps each time you stop/start debug