This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP430G2553:使用 P2.3引脚作为输入时 UART 通信会受到干扰

Guru**** 2538950 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1011164/msp430g2553-uart-communication-is-getting-disturb-while-using-p2-3-pin-as-an-input

器件型号:MSP430G2553

尊敬的 TI:

     在我们的 mspg2553中、我们在引脚 p1.1、p1.2和 p2.3处使用 UART 作为输入引脚。 UART 通信工作正常、而 GPIO p2.3上的输入为低电平、但为高电平。 UART 通信正在受到干扰。 我的意思是、通信速度越来越慢、接收到无效数据。  

这是我的代码、请查看、如果有任何问题、请告知我。

UART 初始化:

 UCA0CTL1 |= UCSSEL_2;                     // SMCLK
    UCA0BR0 = 104;                            // 16MHz 9600
    UCA0BR1 = 0;                              // 16MHz 9600
    UCA0MCTL = UCBRS_0 + UCOS16 + UCBRF_3;    // Modulation UCBRSx = 0
    UCA0CTL1 &= ~UCSWRST;                   // **Initialize USCI state machine**
    IFG2 &= ~(UCA0RXIFG);
    IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt

GPIO:

void initGPIO()
{
    P1DIR |= BIT0;  // DE_RE pin Mode as OUTPUT
    P2DIR |= BIT4;  // B_Led pin Mode as OUTPUT
    P2DIR |= BIT5;  // C_Led pin Mode as OUTPUT
    P2DIR |= BIT6;  // D_Led pin Mode as OUTPUT

    P2DIR |= (BIT1 + BIT2); //(P2.0-DoorLockOperator_A and P2.2  Fan operator)as output

    P2SEL &= ~(doorLockStatus_A);                    // i/o function selected, 0
    P2DIR &= ~(doorLockStatus_A);                    // P1.5 as input
    P2OUT &= ~(doorLockStatus_A);                    // select pull-down mode
    P2REN |= (doorLockStatus_A);                  // Enabling Pull Down Resister


    P1OUT &= ~BIT0; // DE_RE initially Low/receiving mode

    P2OUT &= ~BIT4;  // B_Led LOW Initially/OFF
    P2OUT &= ~BIT5;  // C_Led LOW Initially/OFF
    P2OUT &= ~BIT6;  // D_Led LOW Initially/OFF

    P2OUT &= ~BIT0; //DoorLockOperator_A LOW Initially/OFF
    P2OUT &= ~BIT1; //Optional LOW Initially/OFF
    P2OUT &= ~fanOperator; //FAN Operator LOW Initially/OFF

    P1SEL |= BIT3;  // ADC input pin P1.3

    P1SEL = BIT1 + BIT2;                      // P1.1 = RXD, P1.2=TXD
    P1SEL2 = BIT1 + BIT2;
}

门锁销所在的位置  

#define DoorLockStatus_A BIT3  // P2.3==>P2.0

除此之外、我还有一个 ADC 引脚、但我认为这无关紧要:

// Function containing ADC set-up
static void ConfigureADC()
{
ADC10CTL1 = INCH_3 + ADC10DIV_3; // Channel 3, ADC10CLK/3
ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; // Vcc and Vss as reference, Sample and hold for 64 Clock cycles, ADC interrupt enable
ADC10AE0 |= BIT3; // ADC input enable P1.3
}

如果有任何问题、请告诉我。

谢谢

sarju

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    根据您的描述、我的第一个猜测是 MCU 正在复位。 尝试在 main 的第二行(在停止看门狗之后)上设置断点以查看。

    如果您使用的是 G2ET Launchpad、请不要忘记移除 J8上的 P2.3 (LED)跳线。

    对于魔术和迷信:尝试在某个地方添加"P2SEL &=~BIT7;"。 P2.6和 P2.7以非明显的方式相互作用、但是清除(两个) P2SEL 位似乎使它们具有行为。