Mbed program initiation on power-up

23 Jul 2010

Hi,

The title is kind of useless I know, my question is, is there a way to prevent the mbed from running a program in its memory upon power up, that is, the program could only be triggered when the reset button is pushed, not when it is powered up. I ask this because if I take data in the field with my mbed (run off 5V not usb) and afterwards plug it into the computer, when it is powered up it starts running the program again, and in some cases overwriting my data! I guess it might be easy to add a section of code such that prevents the over-write of data, but it is annoying to have to halt the program every time I want to retrieve data.

 

thanks!

23 Jul 2010

Hi James,

The standard way to avoid a microcontroller running when powered until you want to would be to hold it in reset. On the mbed, this would be achieved by tying the nR pin low, or the reset button.

Alternatively, your program could always run and the logic in your program do different things. e.g. stop immediately if a pin is not set, or wait until it changes before running the bulk of the program (e.g. like having a "record" switch/button).

Hopefully one of those approaches would fit your needs.

Simon

23 Jul 2010

Great, thats an easy solution.

One other thing, does the mbed understand an integer value passed to the wait function?

wait_ms(0.5);

for example.

Is there any other way of getting fractional millisecond wait times? I heard some mumbles about microseconds on some of the time posts. Would that just be:

 

wait_us(12);

 

23 Jul 2010

Hi James,

wait() takes a float argument, whereas wait_ms() and wait_us() take an int argument. So for 0.5ms example, you can write:

wait_us(500);
wait(0.0005);

The underlying time base used to wait is a 1us tick granularity, so is best for delays in the 10us - 10s range.

Simon

24 Oct 2010 . Edited: 24 Oct 2010

Hello Simon,


I found some strange. one procedure get a velue float test and say wait(test). seems ok.

But I have use wait in a For statement, want to wait(1/(note*Point_read)), nort is the frequenzy of a note, Point_read is the number of points in a form written in a File.h, where valuse go from 0 to 1.

I do send data to AnalogOut(P18)

But here I had to multiplay the Wait value with 100????

Also I have started Ethernet, the waiting was much more slower. I do not think that the timing of MPU goes down, more that wait is not correct.

Can you help?