Page Links
MSP430F5529LP Hardware Library: I2C

Overview

This web page provides information about the I2C hardware library created for the MSP430F5529LP Development Board.


Contains


These files are optional. They only need to be included if the I2C functionality is desired. If they are not included, the I2C communications module will remain disabled.

When included, the MSP430F5529LP_I2C.h/c files configure the USCI_B1 hardware peripheral as an I2C communications interface operating in Master mode at 50 KHz. The I2C interface uses two pins. Pin P4.1 is configured as the I2C SDA (Serial Data) signal. Pin P4.2 is configured as the I2C SCL (Serial Clock) signal. These two signals must be connected to all of the I2C communications devices that will be operated on the I2C bus. Each connected I2C device must be operating as a Slave device, and must have a unique address.

This library is intended to be simple in order to make it easy to understand and modify. Minimal error handling support is provided to assist with handling issues that are likely to occur during use. In practice, I2C error handling can become quite extensive

Public Definitions

typedef enum I2C_CompletionCode
    {
        I2C_IN_PROGRESS = 0,
        I2C_COMPLETED_SUCCESS,
        I2C_ARBITRATION_LOST,
        I2C_NACK_RESPONSE
    } I2C_CmplCode_t;
                    
 Placeholder 

Public Functions

void 
    MSP430F5529LP_I2C_Initialize(
        void);
                    
 Calling this function initializes the USCI_B1 hardware peripheral as an I2C communications interface operating in Master mode at 50 KHz. The I2C operates in a 7-bit slave addressing mode. Pin P4.1 is configured as the I2C SDA (Serial Data) signal. Pin P4.2 is configured as the I2C SCL (Serial Clock) signal. The I2C interrupts are enabled, but global interrupts are not. After all initialization is completed, the application must enable global interrupts using "__enable_interrupt();" to begin operation of the I2C module. 
void 
    I2C_Read(
        uint8_t    address,
        uint8_t    *p_reg,
        uint16_t   bytes);
                    
 Placeholder 
void 
    I2C_Write(
        uint8_t   address,
        uint8_t   *p_reg,
        uint16_t  bytes);
                    
 Placeholder 

Example Code

The following example code is provided to demonstrate the functionality of this library. All examples are presented as main.c files, which are available on GitHub. In order to build the example projects, follow the instructions here for how to create and configure a new project.

Example Summary Description
LCD Counting Example using 4-bit Interface
(Coming Soon)
This example demonstrates writing to a 20x4 character LCD module based on the HD44780 display controller using the I2C interface mode. The example uses a blocking delay to set the update speed of an 8-bit up-counter which is displayed in decimal, hexadecimal, and binary formats on the LCD. This example can be used to explore display characteristics such as refresh rate.
Requires: A 20x4 character LCD display based on the HD44780 controller and the LCD_HD44780_4BIT accessory library files.