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.

初始化msp430f5152的UCA0时需要先设置port map吗?

比如使用UCA0TXD和UCA0RXD,如果直接这样设置:

P1SEL|=BIT2+BIT1; 

UCA0CTL1 |= UCSSEL_2; // SMCLK

UCA0BR0 = 69;

UCA0BR1 = 0;  

UCA0MCTL = 0x92;

UCA0CTL1 &= ~UCSWRST;

UCA0IE |= UCRXIE; 

还是需要先设置PORT MAP寄存器呢? 比如这样:

PMAPPWD = 0x02D52; // Enable Write-access to modify port mapping registers
PMAPCTL = PMAPRECFG; // Allow reconfiguration during runtime
P1MAP1 |= PM_UCA0TXD.;

P1MAP2 |= PM_UCA0RXD.;

PMAPPWD = 0; 
P1SEL|=BIT2+BIT1;

  • 根据用户手册上的描述,P1、P2、P3每个IO都可以映射成你想要的功能,例如:P1.1可以映射成UCA0TXD,TA0CCR0的输出、TD0CCR0的输出(这三个功能经测试,是可以实现的)以及其它的功能(没有测试)。 

    这个就看你需要自定义呢,还是选择系统默认的了。

  • 使用默认IO,不需要设置PORT MAP寄存器