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.

G2553与TMP112通信,定时读取数据,为什么进入不了接收中断啊?仿的与TMP100的例程 ,还是有错

Other Parts Discussed in Thread: TMP112, TMP100, MSP430G2553

我在用G2553定时读取进行温度时,为什么进入不了IIC接收中断,我是按照官方的TMP100通信来写的,跑不通,后来也把官方的程序跑了一下(改了地址),也是这样,设置断点,当程序执行到UCB0CTL1 |= UCTXSTT;后全速执行,用示波器采用沿触发观察时钟SCL和数据SDA的输出,观察不到结果,或者只观察到一个很窄的下降沿,然后就没有了,也就是根本不能与TMP112建立通信,我也不知道为什么,板子用的是launchpad,P1.6LED的接头也拔掉了,为什么会有这样的结果,我截了个G2553 的寄存器图,该配置的都配置了,就是中断标志UCB0TXIFG和UCB0STAT结果不对,求解!!!!

下面是程序:

#include <msp430g2553.h>

unsigned int i=0;
unsigned int RxWord,RXByteCtr;

int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT0; // P1.0 output

//设置IIC
P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0
P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0
UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 12; // fSCL = SMCLK/12 = ~100kHz
UCB0BR1 = 0;
UCB0I2CSA = 0x48; // Set slave address
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
IE2 |= UCB0RXIE; // Enable RX interrupt

//设置定时器TimerA
CCR0 = 4096-1; // 计数周期为10s
TACTL = TASSEL_1 + MC_2+ID_3; // ACLK, upmode,8分频
CCTL0 = CCIE; // CCR0 interrupt enabled
__bis_SR_register(GIE);


while(1)
{
RXByteCtr=2;
__bis_SR_register(LPM0_bits);
UCB0CTL1 |= UCTXSTT; // I2C start condition
__bis_SR_register(LPM0_bits);
}


}

//定时器中断,进入后启动温度传输,因为温度为2位,传输两次
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A0 (void)

{

CCR0 += 10000;
P1OUT ^= BIT0; // Toggle P1.0
__bic_SR_register_on_exit(LPM0_bits);

}

//这里仿照G2553例程,主器件接收任意字节数据(2字节) ********不知为什么,程序总是进入不了中断 ?????
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)

{
RXByteCtr--; // Decrement RX byte counter
if (RXByteCtr)
{
RxWord = UCB0RXBUF; // Move RX data to address PRxData
RxWord =RxWord<<8;
if (RXByteCtr == 1) // Only one byte left?
UCB0CTL1 |= UCTXSTP; // Generate I2C stop condition
}
else
{
RxWord|= UCB0RXBUF; // Move final RX data to PRxData
__bic_SR_register_on_exit(LPM0_bits);
}
}