• MSP430F5438A的串口


    设置串口,最关键的是波特率的设置,推荐一个网站,很方便地计算波特率,http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html
    1 P3SEL |= (BIT4 + BIT5);                      // P3.4,5 = USCI_A0 TXD/RXD
    2   UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
    3   UCA0CTL1 |= UCSSEL_2;                     // CLK = SMCLK
    4   UCA0BR0 = 26;                           // 24MHz/57600=26,1,0,1
    5   UCA0BR1 = 0;                           //
    6   UCA0MCTL = UCBRF_1+UCBRS_0+UCOS16;        // Modulation UCBRSx=0, UCBRFx=0,UCOS16 = 1
    7   UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
    8   UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    {
      switch(__even_in_range(UCA0IV,4))
      {
      case 0:break;
      case 2:break;
      case 4:break;
      default:break;
      }
    }

    关键就是UCA0IV 寄存器,通过看文档得知,这是 USCI_Ax Interrupt Vector Register,具体功能如下:

    00h = No interrupt pending,0是无中断
    02h = Interrupt Source: Data received; Interrupt Flag: UCRXIFG; Interrupt
    Priority: Highest,2是数据接收触发中断
    04h = Interrupt Source: Transmit buffer empty; Interrupt Flag: UCTXIFG;
    Interrupt Priority: Lowest,4是数据发送中断

    经常使用的是接收中断,没用过发送中断

  • 相关阅读:
    python字符串以单词形式反转
    python if 语句的练习
    Python对元祖的操作
    Python对列表的操作
    Python对字符串的操作
    导出EXCEL【Web方式HTML通过拼接html中table】
    链接点击跳动问题
    maven报uri is not registered错误
    maven配置
    三级分类的sql语句
  • 原文地址:https://www.cnblogs.com/yaoshunyu/p/10761987.html
Copyright © 2020-2023  润新知