horizon_z40 发表于 2014-11-1 21:11
你好。。我现在在调试G2553的IIC。。调了两天整整。。就是卡在这句。。。请问您解决了吗
void IIC_WriteDevice(uchar DeviceAdds,uchar Adds,uchar Data)
{
UCB0CTL1 |= UCSWRST;
UCB0I2CSA = DeviceAdds;
UCB0CTL1 &= ~UCSWRST;
UCB0CTL1 |= UCTR + UCTXSTT;
UCB0TXBUF = adds;
while((IFG2&UCB0TXIFG)==0);
UCB0TXBUF = data;
while((IFG2&UCB0TXIFG)==0);
UCB0CTL1 |= UCTXSTP;
Delay(200);
}
void Initial_IIC(void)
{
P1SEL |= BIT6 + BIT7;
P1SEL2|= BIT6 + BIT7;
UCB0CTL1 |= UCSWRST;
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC;
UCB0CTL1 = UCSSEL_2 + UCSWRST;
UCB0BR0 = 10;
UCB0BR1 = 0;
UCB0CTL1 &= ~UCSWRST;
}
你试试这个程序。