利用的是I2C例程:msp430g2xx3_uscib0_i2c_03,编译环境是IAR,P1.6为SCL,P1.7为SDA,利用示波器检测两引脚,执行 UCB0CTL1 |= UCTR + UCTXSTT;语句后 ,还一直是高电平。求各位大佬帮忙看一下,蟹蟹!~
程序如下:
#include <msp430.h>
const unsigned char Sine_Tab[] =
{
0xE5
};
int main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |=BIT0;
UCB0CTL1 |= UCSWRST;
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC;
P1SEL |= BIT6 + BIT7;
P1SEL2|= BIT6 + BIT7;
P1REN |= BIT6 + BIT7;
UCB0CTL1 = UCSSEL_2 + UCSWRST;
UCB0BR0 = 12;
UCB0BR1 = 0;
UCB0I2CSA = 0x40;
UCB0CTL1 &= ~UCSWRST;
IE2 |= UCB0TXIE;
UCB0CTL1 |= UCTR + UCTXSTT;
P1OUT ^=0x01;//p1.0
UCB0TXBUF = 0x010;
__bis_SR_register(CPUOFF + GIE);
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB0TX_VECTOR))) USCIAB0TX_ISR (void)
#else
#error Compiler not supported!
#endif
{
static unsigned char ByteCtr;
UCB0TXBUF = Sine_Tab[ByteCtr++]; // Transmit data byte
ByteCtr &= 0x1f; // Do not exceed table
}