EasyManua.ls Logo

Texas Instruments MSP430

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
306
}
void I2C_USCI_set_address(unsigned char address)
{
UCB0CTL1 |= UCSWRST;
UCB0I2CSA = address;
UCB0CTL1 &= ~UCSWRST;
}
unsigned char I2C_USCI_read_byte(unsigned char address)
{
while(UCB0CTL1 & UCTXSTP);
UCB0CTL1 |= (UCTR | UCTXSTT);
while(!(IFG2 & UCB0TXIFG));
UCB0TXBUF = address;
while(!(IFG2 & UCB0TXIFG));
UCB0CTL1 &= ~UCTR;
UCB0CTL1 |= UCTXSTT;
IFG2 &= ~UCB0TXIFG;
while(UCB0CTL1 & UCTXSTT);
UCB0CTL1 |= UCTXSTP;
return UCB0RXBUF;
}
unsigned char I2C_USCI_read_word(unsigned char address,unsigned char *value,
unsigned char length)
{
unsigned char i = 0;
while (UCB0CTL1 & UCTXSTP);
UCB0CTL1 |= (UCTR | UCTXSTT);
while (!(IFG2 & UCB0TXIFG));
IFG2 &= ~UCB0TXIFG;
if(UCB0STAT & UCNACKIFG)
{
return UCB0STAT;
}
UCB0TXBUF = address;
while (!(IFG2 & UCB0TXIFG));
if(UCB0STAT & UCNACKIFG)
{
return UCB0STAT;
}
UCB0CTL1 &= ~UCTR;

Table of Contents

Other manuals for Texas Instruments MSP430

Related product manuals