This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I am trying to interface the 20x4 LCD display with the LAUNCHXL-F280039C
Unfortunately, I am not able to print any character on the display and the display is only showing the boxes on the 1st and 3rd row.
The connection diagram is done as per the below image
//############################################################################# // // FILE: empty_driverlib_main.c // //! \addtogroup driver_example_list //! <h1>Empty Project Example</h1> //! //! This example is an empty project setup for Driverlib development. //! // //############################################################################# // // // $Copyright: // Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the // distribution. // // Neither the name of Texas Instruments Incorporated nor the names of // its contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // $ //############################################################################# //RS = GPIO2 //Enable = GPIO3 //D4 = GPIO10 //D5 = GPIO11 //D6 = GPIO33 //D7 = GPIO48 // // Included Files // #include "driverlib.h" #include "device.h" #include "board.h" #include "c2000ware_libraries.h" #include <stdint.h> #include <stdbool.h> #include <string.h> void lcdGoToXY(char x, char y); void lcdGoToAddr(char addr); void lcdInit(); void lcdClear(); void lcdWriteText(char *text); void sendCommand(char opCode); void sendCommand4Bit(char opCode); int LOW=0; int HIGH=1; // // Main // void main(void) { // // Initialize device clock and peripherals // Device_init(); // // Disable pin locks and enable internal pull-ups. // Device_initGPIO(); // // Initialize PIE and clear PIE registers. Disables CPU interrupts. // Interrupt_initModule(); // // Initialize the PIE vector table with pointers to the shell Interrupt // Service Routines (ISR). // Interrupt_initVectorTable(); // // PinMux and Peripheral Initialization // Board_init(); // // C2000Ware Library initialization // C2000Ware_libraries_init(); // // Enable Global Interrupt (INTM) and real time interrupt (DBGM) // EINT; ERTM; lcdInit(); lcdWriteText("--> Hello world! <--"); lcdGoToXY(1,3); lcdWriteText("http://morf.lv"); lcdGoToXY(2,4); lcdWriteText("Rastro-Mania"); lcdGoToXY(3,0); lcdWriteText("Coding & Engineering"); while(1) { } } void lcdGoToXY(char x, char y) { char addr; switch(x) { case 0: addr = 0x00; break; //Starting address of 1st line case 1: addr = 0x40; break; //Starting address of 2nd line case 2: addr = 0x14; break; //Starting address of 3rd line case 3: addr = 0x54; break; //Starting address of 4th line default: ; } addr +=y; lcdGoToAddr(addr); } void lcdGoToAddr(char addr) { char cmd = 0x80 | addr; GPIO_writePin(RS_pin, LOW); sendCommand4Bit(cmd); } void lcdInit() { //Set all the control pins to logic Zero GPIO_writePin(RS_pin, 0); GPIO_writePin(Enable_pin, 0); //Do the wake up call DEVICE_DELAY_US(20); sendCommand(0x30); DEVICE_DELAY_US(20); sendCommand(0x30); DEVICE_DELAY_US(20); sendCommand(0x30); DEVICE_DELAY_US(20); sendCommand(0x20); //Let's make it 4 bit mode DEVICE_DELAY_US(10); //That's it LCD is initialized in 4 bit mode. sendCommand4Bit(0x28); //N = 1 (2 line display) F = 0 (5x8 characters) sendCommand4Bit(0x08); //Display on/off control D=0,C=0, B=0 sendCommand4Bit(0x01); //Clear Display sendCommand4Bit(0x06); //Entry mode set - I/D = 1 (increment cursor) & S = 0 (no shift) sendCommand4Bit(0x0C); //Display on/off control. D = 1, C and B = 0. (Cursor and blink, last two bits) } void lcdClear() { GPIO_writePin(RS_pin, LOW); sendCommand4Bit(0x01); } void lcdWriteText(char *text) { while( *text) { GPIO_writePin(RS_pin,HIGH); sendCommand4Bit(*text++); } } void sendCommand(char opCode) { GPIO_writePin(D4, opCode & 0x10); GPIO_writePin(D5, opCode & 0x20); GPIO_writePin(D6, opCode & 0x40); GPIO_writePin(D7, opCode & 0x80); } void sendCommand4Bit(char opCode) { GPIO_writePin(D4, opCode & 0x10); GPIO_writePin(D5, opCode & 0x20); GPIO_writePin(D6, opCode & 0x40); GPIO_writePin(D7, opCode & 0x80); GPIO_writePin(Enable_pin,HIGH); GPIO_writePin(Enable_pin,LOW); GPIO_writePin(D4, opCode & 0x01); GPIO_writePin(D5, opCode & 0x02); GPIO_writePin(D6, opCode & 0x04); GPIO_writePin(D7, opCode & 0x08); GPIO_writePin(Enable_pin,HIGH); GPIO_writePin(Enable_pin,LOW); } // // End of File //
I am very new, working on microcontrollers, so if I have done some silly mistake please correct me
Thank you
Hello Vishal,
Which TI device are you using as your microcontroller? Your post says the F28003x, but your diagram is using an MSP device (MSP and C2000 are different families). Also, you will need to be specific when you say that you're not able to display a character; is the LCD a TI-produced product?
If not, and you're certain the problem is with the MCU and not the LCD, then can you please verify the outputs of the GPIO to confirm you are outputting the expected values? If the signals that the GPIO is outputting are not expected, then please confirm the GPIO register configurations in CCS debug mode > Registers.
Best regards,
Omer Amir
Hello Omer,
Actually, connection was same as per the MSP device Image but instead of MSP device I used F28003x (taken the reference for connection).
The initialization and connection of GPIO pins is different.
Thank you for suggesting me to check the GPIO pins, now the lcd display is working well.