MSP430 LCD Interfacing via I2C

Electrical Engineering Asked by Jan Franco on January 4, 2022

I am new at this. I am trying to interfacing 1602A LCD display with MSP430G2553 via PCF8574. When I run the code, nothing happens:

#include <msp430.h>

unsigned int *ptxData;
unsigned int count = 0;
// [0..3] -> power on, [4..5] -> function set, [6..7] -> display off, cursor off, blink off
// [8..9] -> clear screen, [10..11] -> right, do not shift, [12..13] -> display on, cursor on
// [14..15] -> write char 'B'
unsigned int txData[] = {0x03, 0x03, 0x03, 0x02, 0x02, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x06, 0x00, 0x0F, 0x24, 0x22};

void main() {

    // for i2c pins
    P1SEL = 0xC0;
    P1SEL2 = 0xC0;

    // i2c config
    UCB0CTL1 = UCSSEL_3;
    UCB0BR0 = 12;
    UCB0BR1 = 0;
    UCB0I2CSA = 0x27;   // slave address

    // enable tx interrupt
    IE2 |= UCB0TXIE;

    // start to transmit data
    ptxData = txData;

    while (1);

#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void){
    // send txData elements one by one
    UCB0TXBUF = *ptxData;

    // if txData ends, start from beginning
    if (count == 16) {
        count = 0;
        ptxData -= 16;

What am I missing, can you help me?

One Answer

The code is obviously missing comments what it does. If it did have comments what it does or what it is supposed to do, it would be more clear to find out what's wrong.

First of all the transmit data pointer is initialized to null, so it is sending garbage data instead of data from the transmit data array.

Second problem is that the array contains only command nybbles that must be sent to LCD. They are just loaded to GPIO expander data pins, but the LCD RS, RW and E lines are not set at any point for each command nybble, so the commands are not strobed to the LCD.

Answered by Justme on January 4, 2022

Add your own answers!

Related Questions

How to reduce measuring angle of JSN SR04T?

3  Asked on December 27, 2020 by user193395


Battery failing. Oscilloscope?

2  Asked on December 26, 2020 by radod


FT232 Custom Display Name and Device Description

1  Asked on December 22, 2020 by radiofreak1041


Altium won’t let me move object to negative coordinates

1  Asked on December 22, 2020 by mfeinstein


Introducing SiPM Array to an Op-Amp

1  Asked on December 22, 2020 by bestqualityvacuum


LED indicators on Ethernet cables

2  Asked on December 21, 2020 by user3435121


EMI consideration for Microwave Sensor Module

0  Asked on December 20, 2020 by robg


ADS Interdigital stripline filter

0  Asked on December 19, 2020 by simo-zz


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP