Worked like a charm. I was missing that bit about setting a pull-up
resistor, like you said.
Also, reading section 8 of the manual helped a great deal in
understanding the digital I/O.
For any future readers, the line in Mikhail's response:
P1SEL &= ~(BIT3 | BIT¨);
Should read as:
P1SEL &= ~(BIT3 | BIT6);
(for some reason the 6 was rendered incorrectly)
Thank you so much for your help!
--Tom
On Feb 8, 10:02 pm, Mikhail Koslowski <
mikhail.koslow...@gmail.com>
wrote:
> Hi Tom
>
> If you take a look at section 8.2 of slau144i (
http://www.ti.com/litv/pdf/slau144ithis is the datasheet for the whole
> msp430x2xx family) you will find some information about the operation of
> I/O ports and i will mention it in my explanations.
>
> First, i would recommend first that you change this line:
> * P1SEL &= ~BIT3; // Select Port 1
> P1.3 (push button)*
> for this:
> * P1SEL &= ~(BIT3 | BIT¨); // P1.3 and P1.6 as
> I/O*
> This will select the I/O function of both pins (SEL stands for "function
> select"). see sec. 8.2.5 for more details.
>
> Then, for your button to work properly you first have to ask "how it is
> wired?", and if you check the schematics, you will see that one tail is on
> p1.3 and the other is grounded, and now we reach the second question "how
> can a grounded button inputs a logical 1 (high) into the uC?" and the
> answer is "simple": Pull Up resistor.
> I guess all Msp430s have internal resistors, enabled/disabled by software,
> for yours, taking a look at 8.2.4 you will see that there is a PxREN
> register, and there we are going to "enable" a resistor at p1.3:
> * P1REN |= BIT3; // Enable a pull-up/down
> resistor.*
> After that, still in 8.2.4 we can see *"The corresponding bit in the PxOUT
> register selects if the pin is pulled up or pulled down."*, and walking
> into 8.2.2 (PxOUT) we will find out how to set the resistor to pull UP:
> * P1OUT &= ~BIT3; // Sets the resistor to
> pull-UP*
>
> Other parts of your code are fine! with this addons i think it should works
> as expected.
>
> Hope it helps you and others.
> If you still got any questions or if i said something wrong or not clear,
> feel free to tell us!
>
> --
> Mikhail
>
> 2012/2/7 tfoutz99 <
tom.fo...@gmail.com>: