Answer the question
In order to leave comments, you need to log in
Confused with launchpad?
Started mastering launchpad-a. I tried to make a PWM program for a button-driven LED. I ran into a problem that somehow the board reacts incorrectly to the s2 button connected to the p1.3 leg, the
simplest code
#include "io430.h"
void main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= BIT6; //P1.6 назначаем выходом, т.к. там светодиод
P1DIR &= ~BIT3; //P1.3 назначаем входом, т.к. там кнопка
P1REN |= BIT3; //подключаем внутр. резистор к P1.3 и к +
//Теперь на P1.3 высокий уровень всегда, пока кнопка НЕ нажата
while(1)
{
//Если кнопка нажата на P1.3 будет логич. 0
if((P1IN & BIT3) == 0)
P1OUT |= BIT6; //Включаем светодиод
else
P1OUT &= ~BIT6; //Отпустили кнопку - выкл. светодиод
}
}
Answer the question
In order to leave comments, you need to log in
in the examples for MSP430 for connecting internal resistors such a sequence
// Configure Switch on P1.2
P1REN |= BIT2; // P1.2 Enable Pullup/Pulldown
P1OUT = BIT2; // P1.2 pullup
Hmmm... I don't know how to explain it, but the problem was solved by adding P1OUT |= BIT3; before P1REN |= BIT3;
some bits do not take fixed values when power is applied. they need to be forced to initialize. On pic controllers, for example, there is a separate table showing which bits take on which values when reset or power is applied. some are forced not to change. I think the msp430 should have a similar table. you have to look there.
Depending on the version of Launchpad, the layout of the buttons is different, in the first versions (up to 1.4, it seems) pull-up resistors were used, in the latter they were excluded from the circuit and the pull-up had to be done programmatically.
By the way, this can be seen from the examples for different versions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question