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.

MSP430FR5889 UART问题

使用SMCLK时钟,定时器正常,UART也能进入串口发送中断,但是TXD管脚没有电平输出

程序如下


void uart_init()
{
// Configure UART pins
//Set P2.0 and P2.1 as Secondary Module Function Input.
/*

* Select Port 2d
* Set Pin 0, 1 to input Secondary Module Function, (UCA0TXD/UCA0SIMO, UCA0RXD/UCA0SOMI).
*/

GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P2,
GPIO_PIN0 + GPIO_PIN1,
GPIO_SECONDARY_MODULE_FUNCTION
);

// Configure UART
EUSCI_A_UART_initParam param = {0};
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
param.clockPrescalar = 8;
param.firstModReg = 11;
param.secondModReg = 0;
param.parity = EUSCI_A_UART_NO_PARITY;
param.msborLsbFirst = EUSCI_A_UART_LSB_FIRST;
param.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT;
param.uartMode = EUSCI_A_UART_MODE;
param.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION; //EUSCI_A_UART_LOW_FREQUENCY_BAUDRATE_GENERATION;

if(STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A0_BASE, &param))
{
return;
}

EUSCI_A_UART_enable(EUSCI_A0_BASE);
EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE,
EUSCI_A_UART_RECEIVE_INTERRUPT);
EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE,
EUSCI_A_UART_TRANSMIT_INTERRUPT);
// Enable USCI_A0 RX interrupt
EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE,
EUSCI_A_UART_RECEIVE_INTERRUPT); // Enable interrupt
EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE,
EUSCI_A_UART_TRANSMIT_INTERRUPT); // Enable interrupt
__enable_interrupt();

}


//******************************************************************************
//
//This is the USCI_A0 interrupt vector service routine.
//
//******************************************************************************
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(USCI_A0_VECTOR)))
#endif
void USCI_A0_ISR(void)
{
switch(__even_in_range(UCA0IV,USCI_UART_UCTXCPTIFG))
{
case USCI_NONE: break;
case USCI_UART_UCRXIFG:
uart_rx[uart_rx_count++] = EUSCI_A_UART_receiveData(EUSCI_A0_BASE);
break;
case USCI_UART_UCTXIFG:
if(uart_tx_count < uart_tx_num)
{
EUSCI_A_UART_transmitData(EUSCI_A0_BASE,
uart_tx[uart_tx_count]);
}
break;
case USCI_UART_UCSTTIFG: break;
case USCI_UART_UCTXCPTIFG: break;
}
}


void Uart_Tx_IN_AT_MODE(void)
{

uart_tx_num = 0x05;
uart_tx_count = 0;
EUSCI_A_UART_transmitData(EUSCI_A0_BASE,
uart_tx[uart_tx_count++]);
}

void main(void)
{
//Stop watchdog timer
WDT_A_hold(WDT_A_BASE);
//System clk init
clk_init();
//GPIO Init
gpio_init();
//TimerA Init
timer_a_init();
//uart Init
uart_init();

PMM_unlockLPM5();

Uart_Tx_IN_AT_MODE();
while(1)
{
//For debugger
__no_operation();
//Enter LPM0, enable interrupts
__bis_SR_register(LPM3_bits + GIE);

//For debugger
__no_operation();
//Enter LPM0, enable interrupts
// __bis_SR_register(LPM3_bits + GIE);
}

}