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.

MSP430FR2476: I2C 和一个传感器通信,不能连续采集数据?

Part Number: MSP430FR2476

您好,我用例程改了一个通过硬件eUSCI_B  I2C接口控制一个外围传感器,发送采集命令--->连续采集数据,

我发现每运行一次,只能采集一次数据,我单步调试,发现程序停留在最后一行?为什么没有循环调用中断去执行读取数据的动作?非常感谢!

UCB0IE |= UCTXIE0 | UCRXIE0 | UCNACKIE;  //开启了收发,无响应中断,

TXByteCtr = 2;                 // Load TX byte counter,发两个字节命令
while (UCB0CTLW0 & UCTXSTP);                // Ensure stop condition got sent
UCB0CTLW0 |= UCTR | UCTXSTT;             // I2C TX, start condition

__bis_SR_register(LPM0_bits | GIE);          // Enter LPM0 w/ interrupts
// Remain in LPM0 until all data is TX'd
while(1)
{
RXByteCtl = 9;
while (UCB0CTL1 & UCTXSTP);              // Ensure stop condition got sent
UCB0CTLW0 &= ~UCTR;                    // I2C RX
UCB0CTLW0 |= UCTXSTT;                           // I2C start condition
__bis_SR_register(LPM0_bits|GIE);             / / Enter LPM0 w/ interrupt

}

中断处理后,我加了下面这几行,想继续触发RX中断,但是还是不行?

UCB0CTLW0 &= ~UCTR; // I2C RX
UCB0CTLW0 |= UCTXSTT;
UCB0IFG |= UCTXIFG;
RXByteCtl = 9;
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0

谢谢!