Texas Instruments MSP430x1xx Computer Hardware User Manual


 
I
2
C Module Operation
15-5
USART Peripheral Interface, I
2
C Mode
15.2.1 I
2
C Module Initialization
The I
2
C module is part of the USART peripheral. Individual bit definitions when
using USART0 in I
2
C mode are different from that in SPI or UART mode. The
default value for the U0CTL register is the UART mode. To select I
2
C operation
the SYNC and I2C bits must be set. After module initialization, the I
2
C module
is ready for transmit or receive operation. Setting I2CEN releases the I
2
C
module for operation.
Configuring and re-configuring the I
2
C module must be done when I2CEN =
0 to avoid unpredictable behavior. Setting I2CEN = 0 has the following effects:
- I
2
C communication stops
- SDA and SCL are high impedance
- I2CTCTL, bits 3-0 are cleared and bits 7-4 are unchanged
- I2CDCTL and I2CDR register is cleared
- Transmit and receive shift registers are cleared
- U0CTL, I2CNDAT, I2CPSC, I2CSCLL, I2CSCLH registers are unchanged
- I2COA, I2CSA, I2CIE, I2CIFG, and I2CIV registers are unchanged
When re-configuring the USART from I
2
C mode to UART or SPI mode the I2C,
SYNC, and I2CEN bits must first be cleared, then the SWRST must be set and
the UART or SPI initialization procedure must be followed. Failure to follow this
procedure could result in unpredictable operation.
Note: Configuring the USART Module for I
2
C Operation After Reset
The required I
2
C configuration process is:
1) Select I
2
C mode with SWRST = 1 (BIS.B #I2C + SYNC,&U0CTL)
2) Disable the I
2
C module (BIC.B #I2CEN,&U0CTL)
3) Configure the I
2
C module with I2CEN = 0
4) Set I2CEN via software (BIS.B #I2CEN,&U0CTL)
Failure to follow this process may result in unpredictable USART behavior.
Note: Re-Configuring the USART Module for UART or SPI Operation
When re-configuring the USART module for UART or SPI operation from I
2
C
operation, the required process is:
1) Clear I2C, SYNC, and I2CEN (CLR.B &U0CTL)
2) Set SWRST (MOV.B #SWRST,&U0CTL)
3) Continue with UART or SPI initialization procedure.
Failure to follow this process may result in unpredictable USART behavior.