TI中文支持网
TI专业的中文技术问题搜集分享网站

MSP430FR5739 SPI的问题

UCTXIFG is automatically
reset if a character is written to UCxTXBUF.

就是说向发送寄存器送字节后,UCXIFG会自动清零.

为什么我第一次写入后,没有自动清零呢?还是1.

用的LAUNCHPAD仿真看到的…

UCA0CTLW0 |= UCSWRST;                     // **Put state machine in reset**
  UCA0CTLW0 |= UCMST+UCSYNC+UCCKPL+UCMSB+UCSSEL_3;   // 3-pin, 8-bit SPI master Clock polarity high, MSB , SMCLK=DCO
  UCA0BR0 = 0x02;                           // /2  baud
  UCA0BR1 = 0;                              //
  UCA0MCTLW = 0;                            // No modulation
  UCA0STATW|=UCLISTEN;                         //Receive the transmitted;
  UCA0CTLW0 &= ~UCSWRST;                    // **Initialize USCI state machine**
  //UCA0IE |= UCTXIE;                         // Enable USCI_A0 TX interrupt   We will use  no interruption.

 P1SEL1 |= BIT5;  P2SEL1 |= BIT0 + BIT1;

void spiw(unsigned char word)
{
  while((UCA0IFG&UCTXIFG)==0);
  UCA0TXBUF=word;
};

执行到这,写入第一个…但UCTIFG没有自动请0..

Leon Yan:

回复 Peter_Zheng:

33.3.8.1 SPI Transmit Interrupt Operation

The UCTXIFG interrupt flag is set by the transmitter to indicate that UCxTXBUF is ready to accept another character. An interrupt request is generated if UCTXIE and GIE are also set. UCTXIFG is automatically reset if a character is written to UCxTXBUF.

UCTXIFG is set after a PUC or when UCSWRST = 1. UCTXIE is reset after a PUC or when UCSWRST = 1.

所以要记得清零操作,也就是UCB0IFG &= ~(UCRXIFG+UCTXIFG);

Zheng Zhao1:

回复 Peter_Zheng:

还是不可以啊…BUF寄存器根本没移位…,

Zheng Zhao1:

回复 Leon Yan:

可是说明书上说一个字节被写入后,标志可以自动被清零啊..

赞(0)
未经允许不得转载:TI中文支持网 » MSP430FR5739 SPI的问题
分享到: 更多 (0)