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.

[参考译文] MSP430FR2476:MSP430FR2476TRHB UART0 TXD

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1360802/msp430fr2476-msp430fr2476trhb-uart0-txd

器件型号:MSP430FR2476

您好

IC:MSP430FR2476TRHB

UART0:P1.4-TXD0,P1.5--RXD0

UART 0可以进入接收中断、UCA0RXBUF 中的数据是正确的。 单步调试、可以输入发送中断、UCA0TXBUF 中的数据正确、但主机软件无法接收数据。  示波器测试 TXD0端口、无信号输出。

添加 SYSCFG3|=USCIA0RMP;故障依然存在。

主机软件和串行线已排除故障,硬件连接也没有问题。 已尝试多个电路板均为相同故障!

URAT1的配置与 UART0的配置相同、串行端口正常发送和接收数据。

// IO

p1DIR |= 0xff;//将未使用的引脚设置为输出方向
P1SEL0 |= BIT2+BIT4+BIT5;// P1.4-P1.5 UART

//设置 USCI_A0 9600 n 8 1
UCA0CTLW0 |= UCSWRST;//**将状态机置于复位状态**
UCA0CTLW0 |= UCSSEL_2;// SMCLK

// UCA0BR0 = 26;
// UCA0BR1 = 0;
// UCA0MCTLW = 0xB600 | UCOS16 | UCBRF_1;

UCA0BR0 = 52;// 8MHz 9600 (请参阅用户指南)
UCA0BR1 = 0;// 8MHz 9600
UCA0MCTLW = 0x4900 | UCOS16 | UCBRF_1;

UCA0CTLW0 &&~UCSWRST;//**初始化 USCI 状态机**
UCA0IE |= UCRXIE;//启用 USCI_A1 RX 中断

#pragma vector=USCI_A0_vector
__interrupt void USCI_A0_ISR (void)
{
开关(__even_in_range (UCA0IV、4))
{
情形0:中止;//无中断
情形2:// RXIFG
{
RX232_BUFF0[RX23_IndexW0]=UCA0RXBUF;//FIFO
// while ((UCA1IFG&UCRXIFG));

RX232_IndexW0++;
if ((RX232_BUFF0[RX232_IndexW0-2]== 0x0D)&(RX232_BUFF0[RX232_IndexW0-1]== 0x0A))
{
RX232_IndexW0=0;
REC232_FLAG0=1;  

if (RX232_IndexW0 >= RX232BUF_SIZE0)
{
RX232_IndexW0=0;


中断;

情形4:// TXIFG
{
if (TX232_OutLen0>0)//FIFO
{
TX232_OutLen0--;  
UCA0TXBUF= 5232_BUFF0[TX232_IndexR0];
while (! (UCA0IFG&UCTXIFG);
if (++TX232_IndexR0 >= TX232BUF_SIZE0)
{
TX232_IndexR0=0;


否则
{
UCA0IE &=~UCTXIE;  

中断;

默认值:中断;

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

    您能首先尝试一下这个例子吗? 所有这些都使用 UCA0。 如果要更改 GPIO、请检查此代码。  

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /* --COPYRIGHT--,BSD_EX
    * Copyright (c) 2018, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX