Electronics > Microcontrollers

MSP430 LauncPad: ignores wait for button line of code

(1/3) > >>

jproject:
Hello everyone,

I'm in this weird situation and google won't give me the right answers. So... I made a robot that moves in a square area and it works perfectly except for one damn thing! The robot isn't suppose to move until I press the button.
It works perfectly fine when it's powered by the usb and the computer but when I plug in a 3V battery as its power source, the code for the "wait until the fricken button is pressed" is ignored. This is the line of code for wait until button is pushed:

while((P1IN & 0x08) == 0x08);   //Wait until button is pushed

Another program that I use, which uses the exact line of code, does not show any problems when I run it using the 3V battery source. But, the hold button line works if it has some coding in front of it like flash some pretty LEDs, etc. My guess is the initial power up of the LaunchPad makes the line skip for some reason.
Helppppppppppppp pleaseeeeeeeee


Thank you.

joelby:
I haven't seen anything like this, but could it be some sort of power settling/glitching thing?

You could try the following:


* Add a start-up delay before doing anything (tens of milliseconds)
* Implement debouncing for the button in software. Using a simple state machine, detect a button press, wait for a few milliseconds, check if the button is still depressed, and only proceed if it is.

TheDirty:
You're looking for a high value for the push button?  Don't you have it pulled up and push to ground?  It's not floating, is it?

baljemmett:

--- Quote from: TheDirty on June 16, 2011, 02:21:54 pm ---You're looking for a high value for the push button?  Don't you have it pulled up and push to ground?  It's not floating, is it?

--- End quote ---

Unless the MSP430 inverts the input bits or something, that's waiting for a low, isn't it?

jproject:
The switch button uses the pin P1.3 and I have not modified it in any way. The only time the 0x08 is used is in the line for the one I showed it.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version