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 #305 background imageLoading...
Page #305 background image
305
USCI I2C Interfacing DS1307 Real Time Clock (RTC)
This part shows another example of I2C implementation using MSP430’s USCI hardware. This time the
I2C device that is connected with a MSP430 is the popular DS1307 real time clock (RTC). This is the
last USCI hardware example.
Code Example
HW_I2C.h
#include <msp430.h>
void I2C_USCI_init(unsigned char address);
void I2C_USCI_set_address(unsigned char address);
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);
HW_I2C.c
#include "HW_I2C.h"
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;

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