EasyManuals Logo

Texas Instruments MSP430 User Manual

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
Page #304 background imageLoading...
Page #304 background image
304
void I2C_USCI_init(unsigned char address)
{
P1DIR &= ~(BIT6 + BIT7);
P1OUT |= (BIT6 + BIT7);
P1SEL2 |= (BIT6 | BIT7);
P1SEL |= (BIT6 | BIT7);
UCB0CTL1 |= UCSWRST;
UCB0CTL0 = (UCMST | UCMODE_3 | UCSYNC);
UCB0CTL1 = (UCSSEL_2 | UCSWRST);
UCB0BR0 = 20;
UCB0I2CSA = address;
UCB0CTL1 &= ~UCSWRST;
}
Off all the functions used in the HW_I2C files, the following are of high importance:
unsigned char I2C_USCI_read_byte(unsigned char address);
unsigned char I2C_USCI_read_word(unsigned char address,unsigned char *value,
unsigned char length);
unsigned char I2C_USCI_write_byte(unsigned char address, unsigned char value);
Their names suggest their functionality. The codes inside them are arranged as such that they take
care of start-stop conditions generation, clock generation, etc. I2C communication needs device
address along side read-write info. Based on read-write info, the host device writes or read I2C bus.
The drawback of using I2C with these functions is the vulnerability to falling inside a loop since loops
are used in these functions widely. This setback can be overcome with timeouts.
Demo
Demo video: https://youtu.be/RkTjCcCLEDg.

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals