Our Raspberry Pi friends will know the Building a Low Power Compact LCD Display project that shabaz published a while ago. He designed a £5 LCD module and the source code for Raspberry Pi.

I've ported it to the TI-RTOS I2C driver.

The display code should work on MSP432, CC1X and CC2X families. I tested it on a CC1310 Sub-1 GHz LaunchPad.

Take care to read shabaz' blog first. It's a good read and this blog builds upon the information.


SimpleLink Drivers for TI-RTOS


The SimpleLink TI-RTOS supports a single API across the whole gamma of SimpleLink microcontrollers.

In this code I'll only use the SimpleLink I2C driver API.

I've adapted Shabaz' code as little as I could. I've changed a few variable and parameter types to match those of the TI driver.


An example of a changed API function ts the i2c_open() call, where I added the I2C bus speed as parameter.


int i2c_open(unsigned char bus, unsigned char addr)


I2C_Handle i2c_open(uint_least8_t index, uint_least8_t addr, I2C_BitRate bitRate)


In Linux, an I2C handle is an int. In TI-RTOS it has a dedicated type called I2C_Handle. That's why the function has a different return type.

The I2C interface number to use and I2C slave address are a of a different type too.

Because the code is expected to be compatible with many controllers, I've not assumed a bus speed in te code. The user will have to provide it when using it.


For the other functions and implementation code, I only changed types and the actual I2C API calls.

Example, from:

int i2c_write(int handle, unsigned char* buf, unsigned int length)
  if (write(handle, buf, length) != length)
    fprintf(stderr, "i2c_write error: %s\n", strerror(errno));


size_t i2c_write(I2C_Handle handle, unsigned char* buf, size_t length)
    I2C_Transaction i2cTransaction;
    size_t retval = length;
    /* Common I2C transaction setup */
    i2cTransaction.writeBuf = buf;
    i2cTransaction.writeCount = length;
    i2cTransaction.readCount = 0;
    i2cTransaction.slaveAddress = _slaveAddress;

    if (!I2C_transfer(handle, &i2cTransaction)) {
        retval = 0;
    return (retval);


Hardware and Connections


You'll need 4 connections. 2 for the 3V3 DC power and 2 I2C lines.

Here's an example for the SimpleLink CC1310 LaunchPad:



Adapting to Your Design


The I2C pull-up is a little high in my case, because both the LaunchPad and LCD board have the pull-up resistors mounted.

In a real situation you would only populate one set of resistors.


Depending on what address you configured on the LCD board, you may have to change your code.

My board was configured for address 0x62.

#define DEVICE_ADDR 0x62 /* this is different than the GIT code. The PCB is configured for 0x62 instead of 0X60 */


Select the I2C port and speed to use when initialising. This can depend on the controller or LaunchPad you're using.



The Code Composer Studio project is attached.


Related Blog
Building a Low Power Compact LCD Display - Port to Hercules Safety Microcontroller
Building a Low Power Compact LCD Display - I2C Traffic
Building a Low Power Compact LCD Display - Port to SimpleLink TI-RTOS