• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD Test with MSP432 (Troubleshoot)

TerryC03

New Member
Hi All,

New here, I had a question (I searched, but couldn't find any thread similar.) I was wondering if anyone was willing to help me troubleshoot on why my LCD 16x2 isn't receiving the commands. I'm just trying to turn on the cursor and display two lines:

C:
#include "msp.h"


/**
 * main.c
 */

//Pin assignments for P4
#define rs 0x01
#define rw 0x02
#define e 0x04

void pinAssign(){
    P9->DIR |= 0xFF; //8-bit Data bus
    P4->DIR |= 0x07;
}
void lcdCommand(unsigned char command){
    pinAssign();
    P9->OUT |= command;
    P4->OUT |= e + rs;
    delay(500);
    P4->OUT &= ~e;
}
void lcdData(unsigned char data){
    pinAssign();
    P9->OUT |= data;
    P4->OUT |= e + rs;
    delay(500);
    P4->OUT &= ~e;


}

//The idea I had was to create a function to send the data to the LCD.
void lcd_init(){
    lcdCommand(0x38);
    delay(200);
    lcdCommand(0x0C);
    delay(200);
    lcdCommand(0x01);
    delay(200);
    lcdCommand(0x80);
    delay(200);
}
void main(void)
{
    WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD;        // stop watchdog timer
    lcd_init(); //Start all of the commands: 2 lines with blinking cursor.
    int i = 0;
}
I'm experimenting with the MSP432 microcontroller. Thanks in advance. And please tell or point me to the proper etiquette of posting here.
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
LCD initialising requires a bit more than you supplied... You must allow 15~20mS before trying to write to it.. Then send 0x33 three times
C:
void lcd_init(){
    delay(20); /// MAKE SURE THESE DELAYS ARE MS
    lcdCommand(0x33);
    delay(5);
    lcdCommand(0x33);
    delay(5);
    lcdCommand(0x38);
    delay(2);
    lcdCommand(0x0C);
    delay(2);
    lcdCommand(0x01);
    delay(2);
    lcdCommand(0x80);
    delay(2);
}
 

TerryC03

New Member
LCD initialising requires a bit more than you supplied... You must allow 15~20mS before trying to write to it.. Then send 0x33 three times
C:
void lcd_init(){
    delay(20); /// MAKE SURE THESE DELAYS ARE MS
    lcdCommand(0x33);
    delay(5);
    lcdCommand(0x33);
    delay(5);
    lcdCommand(0x38);
    delay(2);
    lcdCommand(0x0C);
    delay(2);
    lcdCommand(0x01);
    delay(2);
    lcdCommand(0x80);
    delay(2);
}
Hi, and thanks for the quick reply! However, this code isn't helping either; nothing "turned on." The delay() function is in milliseconds. Also, I don't see a (0x33) command for the LCD. What should that do?
 

Latest threads

EE World Online Articles

Loading

 
Top