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.

[参考译文] MSP430F5438A:UART 不工作! 我参考了一个示例。

Guru**** 2526700 points
Other Parts Discussed in Thread: MSP430F5438A, MAX232, MSP430F5529

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1121493/msp430f5438a-not-working-uart-i-referred-to-an-example

器件型号:MSP430F5438A
主题中讨论的其他器件: MSP-TS430PZ5X100MAX232MSP430F5529

大家好、Texas Team 或 Expert

我的 MCU 必须 与 MSP430F5438A 进行 RS232通信。

我在 CCS Resource Explorer 中找到了 UART 环回示例、然后下载了固件。

但也有 问题。 使用 Hercules 或 CCS 时终端无法正常工作。

此外、如果我设置 transmitData ='A'、我将 TX (TX-GND)或 RX (RX-GND)连接到示波器、但数据值未检查。

问题出在哪里?

我设计的 MCU 和 RS232 (带 USB)

电路板:MSP-TS430PZ5x100 (MSP430F5438A)

代码:  

//******************************************************************************
//! This example shows how to configure the UART module as the loopback to
//! verify that received data is sent data.
//!
//!               MSP430F5438A
//!             -----------------
//!       RST -|     P3.4/UCA0TXD|----|
//!            |                 |    |
//!            |                 |    |
//!            |     P3.5/UCA0RXD|----|
//!            |                 |
//!
//!
//! This example uses the following peripherals and I/O signals.  You must
//! review these and change as needed for your own board:
//! - UART peripheral
//! - GPIO Port peripheral (for UART pins)
//! - UCA0TXD
//! - UCA0RXD
//!
//! This example uses the following interrupt handlers.  To use this example
//! in your own application you must add these interrupt handlers to your
//! vector table.
//! - USCI_A0_VECTOR.
//******************************************************************************
#include "driverlib.h"

//*****************************************************************************
//
//Select Baud rate
//
//*****************************************************************************
#define BAUD_RATE                               9600
//*****************************************************************************
//
//Initialize received data
//
//*****************************************************************************
uint8_t receivedData = 0x00;
//*****************************************************************************
//
//Initialize transmit data
//
//*****************************************************************************
uint8_t transmitData = 0x00;

uint8_t check = 0;

void main (void)
{
    //Stop WDT
    WDT_A_hold(WDT_A_BASE);

    //P3.4,5 = USCI_A0 TXD/RXD
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3, GPIO_PIN4 + GPIO_PIN5);

    //Baudrate = 9600, clock freq = 1.048MHz
    //UCBRx = 109, UCBRFx = 0, UCBRSx = 2, UCOS16 = 0
    USCI_A_UART_initParam param = {0};
    param.selectClockSource = USCI_A_UART_CLOCKSOURCE_SMCLK;
    param.clockPrescalar = 109;
    param.firstModReg = 0;
    param.secondModReg = 2;
    param.parity = USCI_A_UART_NO_PARITY;
    param.msborLsbFirst = USCI_A_UART_LSB_FIRST;
    param.numberofStopBits = USCI_A_UART_ONE_STOP_BIT;
    param.uartMode = USCI_A_UART_MODE;
    param.overSampling = USCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION;

    if (STATUS_FAIL == USCI_A_UART_init(USCI_A0_BASE, &param)){
        return;
    }

    //Enable UART module for operation
    USCI_A_UART_enable(USCI_A0_BASE);

    //Enable Receive Interrupt
	USCI_A_UART_clearInterrupt(USCI_A0_BASE, USCI_A_UART_RECEIVE_INTERRUPT);
    USCI_A_UART_enableInterrupt(USCI_A0_BASE, USCI_A_UART_RECEIVE_INTERRUPT);

    __bis_SR_register(GIE);

    while (1)
    {
    		transmitData = transmitData+1;                      // Increment TX data
        // Load data onto buffer
        USCI_A_UART_transmitData(USCI_A0_BASE,
        		transmitData);
        while(check != 1);
        check = 0;
    }
}

//******************************************************************************
//
//This is the USCI_A0 interrupt vector service routine.
//
//******************************************************************************
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR (void)
{
    switch (__even_in_range(UCA0IV,4)){
        //Vector 2 - RXIFG
        case 2:
            receivedData = USCI_A_UART_receiveData(USCI_A0_BASE);
            if(!(receivedData == transmitData))                   // Check value
            {
              while(1);
            }
            check =1;
            break;
        default: break;
    }
}

或地址: https://dev.ti.com/tirex/explore/node?node=AHTWzeTf6uwMxTvmqYEvag__IOGqZri__LATEST //   

有人可以帮帮我吗?

 

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

    您是否将这两个引脚连接在一起?

    在调试模式下运行器件时是否有异常现象?

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

    大家好、周奕迅

    我连接 MCU TX、RX - US232 - MyComputer (USB)。

    在调试模式下 、我无法连接恢复命令上的终端

    这是错误的。

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

    很抱歉,我无法清楚地理解你。  

    您的问题是否在于代码示例不能按您想要的方式运行?  

    我无法理解为什么在运行该代码示例时需要连接 COM 端口。

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

    问题是我没有设计 max232、因为我没有考虑 TTL。 代码不起作用。  我将购买 MAX232  

    我的目的是使用 USB 转 RS232转换器与 MCU 和 PC 进行通信。

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

    如果您的意思是 UART 代码无法正常工作、我可以在下周为您试用。

    如果您希望与 MCU 和 PC 通信、也可以使用 MSP430F5529、它具有 USB 外设和 LaunchPad。