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.

LCD display

Hi there,

I am using an TMS32F28335 and i want to send a message to the LCD.I want an example(the easiest),just to have an idea of how to do it.Thank you for helping me.

 

Best regards,

Morcoase Florin

  • Hi,

    Morcoase Florin said:

    Hi there,

    I am using an TMS32F28335 and i want to send a message to the LCD.I want an example(the easiest),just to have an idea of how to do it.Thank you for helping me.

     

    Best regards,

    Morcoase Florin

    There are no example codes for LCD interface.Try this out:

    0871.1106.LCD4BIT.c
    #include "PeripheralHeaderIncludes.h"
    
    #define RS GpioDataRegs.GPADAT.bit.GPIO4
    #define EN GpioDataRegs.GPADAT.bit.GPIO5
    
    #define DATA_PORT  GpioDataRegs.GPADAT.all
    
    void LCD_init(void);
    void LCD_cmd(unsigned char);
    void LCD_dat(unsigned char);
    void delay_ms(long end);
    void DeviceInit(void);
    void InitFlash(void);
    
    void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr);
    
    extern Uint16 RamfuncsLoadStart, RamfuncsLoadEnd, RamfuncsRunStart;
    
    unsigned char i,temp;
    
    const unsigned char Msg1[] = "16x2 LCD Test...";
    const unsigned char Msg2[] = "F2812 EVB BOARD ";
    
    void main(void)
    {
    	DeviceInit();	// Device Life support & GPIO mux settings
    
    #ifdef FLASH		
    	MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
    	InitFlash();	// Call the flash wrapper init function
    #endif 
    	
    	delay_ms(1000);
    	LCD_init();
    	delay_ms(500);
    	
        while(1)
        {
         //   LCD_cmd(0x01);	
         //   delay_ms(50);
    
            LCD_cmd(0x80);			// First line	
            for(i=0;i<16;i++)
            { 
                LCD_dat(Msg1[i]);
                delay_ms(5);
            }
    
            LCD_cmd(0xc0);			// Second Line
            for(i=0;i<16;i++)
            { 
                LCD_dat(Msg2[i]);
                delay_ms(5);
            }
        }
    } 
    
    void LCD_init(void)
    {	
        LCD_cmd(0x33);
    	LCD_cmd(0x32);
    	LCD_cmd(0x28);		// 38 for 8 data lines , 28 for 4 data lines use D4-D7 MSB Lines.
        LCD_cmd(0x0c);	
        LCD_cmd(0x06);
        LCD_cmd(0x01);   
    }
    		
    void LCD_cmd(unsigned char cmd)
    {
    	RS = 0;
    	
    	temp = ((cmd & 0xF0)>>4);
    	DATA_PORT = temp;
        EN = 1;
        EN = 0;
        
     
        temp = cmd & 0x0F;
    	DATA_PORT = temp;
        EN = 1;
        EN = 0;
    	delay_ms(3);
    }
    
    void LCD_dat(unsigned char byte)
    {
    	RS = 1;
    	
    	temp = ((byte & 0xF0)>>4);
    	DATA_PORT = temp;
        EN = 1;
        EN = 0;
        
    	temp = byte & 0x0F;
    	DATA_PORT = temp;
        EN = 1;
        EN = 0;
    	delay_ms(3);
    }
    
    void delay_ms(long end)
    {
    	long i;
    	end = 3573 * end;
    	for (i = 0; i < end; i++);
    }
    
    

    Though you can find some suggestions on this forum if you search thoroughly.

    Regards,

    Gautam

  • Morcoase Florin said:
    I want to send a message to the LCD

    I run a Display firm - LCDs, TFTs, OLEDs.  Your, "the Lcd" - while, "clear to you" - not so much - all others.  Realize there are easily 100+ "standard" character & graphic format Lcds.  Sending a message varies based upon the Lcd of choice.

    A most general format demands an entire, 8 bit data port (often bi-di) and a 2nd port for control signals & strobes.  The data port is loaded - followed by the control signals & lastly data strobe.  The 4 bit code suggested by another condemns you to character-only - and the initialization & set-up/config of 4 bit mode bedevils many.  (thus my suggestion of 8 bits - which enables character and later, graphic)

    Graphic screens are far more difficult to control than character-only displays.  And I'm just speaking mono - to begin.  Throw in color - difficulty expands exponentially.

    Attention to detail is normal/customary w/these MCUs - less so w/displays - but you'll have to do bit better than, "the Lcd!"