主题中讨论的其他器件:MSP-EXP430F5529LP
大家好、我正在尝试在 MSP-EXP430F5529LP (MSP5529 LaunchPad)上使用 UART。 我已将 SMCLK 配置为4MHz、 并尝试将 UART 配置为以115200kbps 的速率运行。 我通过仅发送一个字符'A'(0x41)开始简单。 我将示波器连接到 PIN3.3并触发以查看波形、以确认我的 UART 正在执行它应该执行的操作
下面是我对其进行配置的代码:
#include <msp430f5529.h>
void ConfigUCS (void)
//Configure SMCLK to 4MHz
{
P5SEL |= BIT2 | BIT3;//Configure IO as XT2 function
UCSCTL6 &= ~XT2OFF;//Enable XT2
UCSCTL4 |= SELA_2;//first configure ACLK source as REFCLK
UCSCTL3 |= SELREF_2;//Configure FLLCLK source as REFCLK
while (SFRIFG1 & OFIFG) {
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);//Clear the three types of clock flags
//There are three flag bits that need to be cleared because any
//The flag bit will set OFIFG
SFRIFG1 &= ~OFIFG;//Clear clock error flag
}
UCSCTL4 = UCSCTL4 & (~(SELS_7 | SELM_7)) | SELS_5 | SELM_5;//Configure SMCLK and MCLK clock sources as XT2
//P2SEL |= BIT2;
//P2DIR |= BIT2;//For measuring SMCLK
return;
}
void ConfigURART (void)
{
UCA0CTL1 |= UCSWRST; // Software reset of UCA0 module
UCA0CTL0 |= UCMSB; // Initialize control register UCA0XTL0
// default is no Parity / MSB first / 8bit / One stop bit / UART / Asynchrnoous mode
UCA0CTL1 |= 0x00; // Initialize control register UCA0CTL1
UCA0CTL1 |= UCSSEL_2;// Set SMCLK (SMCLK is at 4MHz) to BRCLK.
UCA0MCTL |= UCOS16; // Oversampling mode
// N = 4,000,000/115,200 = 34.722
UCA0BR1 |= 0x00;
UCA0BR0 |= 0x02; // UCBR0 = INT (N/16) = 2
UCA0MCTL|= UCBRF1; // UCBRF0 = 2
UCA0MCTL|= UCBRS1 + UCBRS0; // UCBRS0 = 3
P3SEL |= BIT3 + BIT4;// Port Configuration
UCA0CTL1 &= ~UCSWRST; // Software reset of UCA0 module cleared
}
/**
* main.c
*/
int main(void)
{
ConfigUCS();
ConfigURART();
UCA0TXBUF = 'A';
}
SMCLK 配置正确、因为我可以在 P2.2上测量4MHz 时钟。 但是、当我将示波器放在 P3.3 (UCA0TXD)上时、我得到了非常奇怪的波形。 波形几乎表明硬件方面有问题。 我是否在配置中出错、或者我的硬件有某种程度的损坏?
以下是示波器捕获:

C1是 P3.3处的 x10探针。 据我了解、当不传输时、UART 总线应该为3.3V、但在这里、我看到一些低于200mV 的无用信号...有什么想法吗? 谢谢。






