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.

Compiler/MSP430G2553: LCD display with MSP430G2553 for IAR Embedded Workbench

Part Number: MSP430G2553
Other Parts Discussed in Thread: ENERGIA

Tool/software: TI C/C++ Compiler

Hi,

I am trying to display on the LCD the battery voltages & currents by reading the ADC values from MSP430.

By using Energia IDE & Launchpad i am able to display on the LCD and its working fine.

But i need to use IAR embedded workbench to display these values ,any example code and libraries for the LCD would help.

I am using JHD162A LCD , any compatible libraries & drivers for it also helps.

Regards,

Phanendra

  • Hi Phanendra,

    Since this LCD display is not a TI product - we do not have any direct examples to send you for this specific application.

    There are other threads, however, which customers use this or other LCD modules which may be of reference to you:

    Here is another resource I have found via the web that may be of help as well.

    Thanks,

    -Chris

  • Dear Chris,

    Ok Thanks, but i need example codes,because through energia IDE i am able to get all the values and integrate the system.

    But to have code privacy i need to get it done on IAR embedded systems.

    Regards,

    Phanendra

  • One more thing,I need to print the data that is receiving on the RX pin of the MSP430 on to the LCD.

  • Hi Chris,

    Please update on it.

    I am able to integrate and LCD with IAR but able to see only black dots.I am printing String but not able to see any thing on LCD.

    Should we use level shifters for it or any certain frequency rate.

  • /*
     * libLCD.h
     *
     * Header file written for Basic 16x2 Character LCD from SparkFun.
     * (www.sparkfun.com/.../9053)
     * Should work for any display utilizing the common
     *    ST7066 / HD44780 parallel interface in 4-bit mode.
     * Making this work for 8-bit mode should only require adjusting some
     * of the pin definitions below and adjusting some of the initializations.
     *
     *  Created on: Oct 18, 2012
     *      Author: Stephen Bennett
     */
    
    #ifndef LIBLCD_H_
    #define LIBLCD_H_
    
    /****************************\
    |* Standard MSP430 includes *|
    \****************************/
    #include <msp430.h>
    
    /* Microcontroller clock speed - used for timing calculations */
    #define     MCU_XTAL_CLK      1000000
    #define     MCU_XTAL_TIME     ((MCU_XTAL_CLK) / 1000)
    
    /* Convert milliseconds to clock cycles. */
    #define     _delay_milliseconds(msecs) \
                   __delay_cycles(((msecs) * (MCU_XTAL_TIME)))
    
    
    /***************************************\
    |* Define Ports Used for Communication *| For now, all pins should be on the same port
    \***************************************/
    /* Data pins must be on same port */
    //#define     LCD_DIR_DATA      P2DIR
    //#define     LCD_OUT_DATA      P2OUT
    
    /* Reg Select Port */
    //#define     LCD_DIR_RS        P2DIR
    //#define     LCD_OUT_RS        P2OUT
    
    /* Read/Write Port */
    //#define     LCD_DIR_RW        P2DIR
    //#define     LCD_OUT_RW        P2OUT
    
    /* Enable Port */
    //#define     LCD_DIR_EN        P2DIR
    //#define     LCD_OUT_EN        P2OUT
    
    
    /*************************************\
    |* Define Pins Used for Communication*|
    \*************************************/
    /* Data pins must be consecutive & ascending */
    #define     LCD_PIN_D4        BIT2
    #define     LCD_PIN_D5        BIT3
    #define     LCD_PIN_D6        BIT4
    #define     LCD_PIN_D7        BIT5
    
    #define     LCD_PIN_RS        BIT6
    //#define     LCD_PIN_RW        BIT6
    #define     LCD_PIN_EN        BIT7
    
    #define     LCD_MASK_DATA     (LCD_PIN_D7 | LCD_PIN_D6 | LCD_PIN_D5 | LCD_PIN_D4)
    
    
    /*****************************************\
    |* Define Useful Display Characteristics *|
    \*****************************************/
    #define     LCD_NUM_COLS      16
    #define     LCD_NUM_ROWS      2
    
    
    /***************************\
    |* Define Display Commands *|
    \***************************/
    /* Function Set Defines */
    #define     FUNCTION_SET      0x20  // Must be set to execute FUNCTION_SET_CMD
    #define     INTFC_DATA_LEN    0x10  // HIGH: 8-bit interface | LOW: 4-bit interface
    #define     TWO_LINE_DISP     0x08  // HIGH: 2-line display | LOW: 1-line display
    #define     CHAR_FONT_SIZE    0x04  // HIGH: 5x10 dots | LOW: 5x8 dots (only usable with 1-line display)
    /* Function Set Command - modify to liking */
    #define     FUNCTION_SET_CMD  (FUNCTION_SET | TWO_LINE_DISP)
    
    /* Display Initialization Defines */
    #define     DISPLAY_ON        0x08  // Must be set to execute DISPLAY_ON_CMD
    #define     ENTIRE_DISP_ON    0x04
    #define     CURSOR_ON         0x02  // Show the cursor at current position
    #define     CURSOR_BLINK_ON   0x01  // Make the cursor blink
    /* Display Initialization Command - modify to liking */
    #define     DISPLAY_ON_CMD    (DISPLAY_ON | ENTIRE_DISP_ON | CURSOR_ON)
    
    /* Entry Mode Initialization Defines */
    #define     ENTRY_MODE        0x04  // Must be set to execute ENTRY_MODE_CMD
    #define     CURSOR_INCR       0x02  // Cursor increment on character write, else decrement
    #define     DISPLAY_SHIFT_ON  0x01  // Shift display according to CURSOR_INCR
    /* Entry Mode Initialization Command - modify to liking */
    #define     ENTRY_MODE_CMD    (ENTRY_MODE | CURSOR_INCR)
    
    /* Miscellaneous Commands */
    #define     CLEAR_DISP_CMD    0x01  // Clear the display
    #define     RET_HOME_CMD      0x02  // Return cursor to top left (0,0)
    
    
    /****************************\
    |* Useful Data Type Defines *|
    \****************************/
    #define     COMMAND           0
    #define     DATA              1
    typedef     unsigned char     uint8_t;
    
    
    /******************************\
    |* Public Function Prototypes *|
    \******************************/
    void LCD_init(void);
    void LCD_printStr(char *text);
    void LCD_printChar(char character);
    void LCD_sendCommand(char command);
    void LCD_setCursorPosition(uint8_t row, uint8_t col);
    void LCD_clearScreen(void);
    
    #endif
    
    
    
    
    /*
     * libLCD.c
     *
     *  Created on: Oct 18, 2012
     *      Author: Stephen Bennett
     */
    
    #include "lcdLib.h"
    
    
    /******************************\
    |* Helper Function Prototypes *|
    \******************************/
    void LCD_sendCommand(char command);
    void LCD_sendByte(char byteToSend, uint8_t byteType);
    void LCD_sendNibble(char nibbleToSend);
    void LCD_pulseEnablePin(void);
    
    
    /********************\
    |* Public Functions *|
    \********************/
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_setCursorPosition
    |*
    |*    Set the position of the cursor on the screen.
    |*
    |* PARAMETERS
    |*
    |*    ** Does not check row/col limits **
    |*    row - zero based row number < LCD_NUM_ROWS
    |*    col - zero based col number < LCD_NUM_COLS
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_setCursorPosition(uint8_t row, uint8_t col)
    {
       uint8_t address;
    
       /* Construct address from (row, col) pair */
       if (row == 0)
       {
          address = 0;
       }
       else
       {
          address = 0x40;
       }
    
       address |= col;
    
       LCD_sendCommand(0x80 | address);
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_clearScreen
    |*
    |*    Clear the screen data and return the cursor to home position (0, 0).
    |*    Automatically sets the cursor to increment.
    |*    Display shifting is unaffected.
    |*
    |* PARAMETERS
    |*
    |*    void
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_clearScreen(void)
    {
       LCD_sendCommand(CLEAR_DISP_CMD);
       LCD_sendCommand(RET_HOME_CMD);
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_init
    |*
    |*    Initialize the LCD after power-up
    |*
    |* NOTE:
    |*    This routine must not be called twice on the LCD.
    |*    This is not uncommon when the power for the MCU and LCD are separate.
    |*
    |* PARAMETERS
    |*
    |*    void
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_init(void)
    {
       /* Set the MSP pin configurations and bring them LOW */
       P2DIR |= LCD_MASK_DATA;
       P2DIR   |= LCD_PIN_RS;
       P2DIR   |= LCD_PIN_EN;
    
       P2DIR &= ~(LCD_MASK_DATA);
       P2DIR   &= ~LCD_PIN_RS;
       P2DIR   &= ~LCD_PIN_EN;
    
       /* Wait for the LCD to warm up and reach active regions.
        * Remember MSPs can power up much faster than the LCD.
        * (At least 40ms after Vcc rises above 2.7V)
        */
       _delay_milliseconds(80);
    
       /*****************************\
       |* Initialize the LCD module *|
       \*****************************/
       /* According to Hitachi HD44780 datasheet (fig 24, pg 46) */
    
       /* 1a. Set to 4-bit input - try three (3) times */
       uint8_t i = 3;
       while (i != 0)
       {
          LCD_sendNibble(0x03);
          _delay_milliseconds(5);
          --i;
       }
    
       /* 1b. Set to 4-bit interface */
       LCD_sendNibble(0x02);
       _delay_milliseconds(1);
    
       /* 1c. Set number of lines, font size, etc. */
       LCD_sendCommand(FUNCTION_SET_CMD);
       _delay_milliseconds(1);
    
       /* 2. Initialize display
        *    Turn display on/off, cursor on/off, cursor blinking on/off
        */
       LCD_sendCommand(DISPLAY_ON_CMD);
       _delay_milliseconds(1);
    
       /* 3. Initialize entry mode
        *    Text direction, cursor move, display shifting, etc.
        */
       LCD_sendCommand(ENTRY_MODE_CMD);
       _delay_milliseconds(1);
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_printStr
    |*
    |*    Print a string of characters to the screen.
    |*
    |* PARAMETERS
    |*
    |*    text - NULL terminated string of chars
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_printStr(char *text)
    {
       char *c;
       c = text;
    
       while ((c != 0) && (*c != 0))
       {
          LCD_sendByte(*c, DATA);
          c++;
       }
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_printChar
    |*
    |*    Print a character to the screen.
    |*
    |* PARAMETERS
    |*
    |*    character - character to be printed
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_printChar(char character)
    {
       LCD_sendByte(character, DATA);
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_sendCommand
    |*
    |*    Send a command to the LCD on the data bus in 4 bit mode.
    |*
    |* PARAMETERS
    |*
    |*    command - command to send
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_sendCommand(char command) {
       LCD_sendByte(command, COMMAND);
    }
    
    
    /********************\
    |* Helper Functions *|
    \********************/
    
    /*-------------------------------------------------------------------------*\
    |* HELPER FUNCTION :: LCD_sendByte
    |*
    |*    Send a byte on the data bus in 4 bit mode.
    |*    This requires sending the data in two chunks.
    |*    High nibble first, then low nibble.
    |*
    |* PARAMETERS
    |*
    |*    byteToSend - single byte to send
    |*    byteType   - either DATA or COMMAND
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_sendByte(char byteToSend, uint8_t byteType)
    {
       /* Set Reg Select line to appropriate mode (HIGH: data | LOW: command) */
       if (byteType == COMMAND)
       {
          P2DIR &= ~LCD_PIN_RS;
       }
       else // (byteType == DATA)
       {
          P2DIR |= LCD_PIN_RS;
       }
    
       /* set High Nibble (HN) on data lines */
       LCD_sendNibble( (byteToSend & 0xF0) >> 4);
    
       /* set Low Nibble (LN) on data lines */
       LCD_sendNibble( byteToSend & 0x0F);
    }
    
    /*-------------------------------------------------------------------------*\
    |* HELPER FUNCTION :: LCD_sendNibble
    |*
    |*    Send a nibble on the data bus in 4 bit mode.
    |*
    |* PARAMETERS
    |*
    |*    byteToSend - single byte to send
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_sendNibble(char nibbleToSend)
    {
       /* Clear out all data pins */
       P2DIR &= ~(LCD_MASK_DATA);
    
       /* Set the nibble */
       P2DIR |= nibbleToSend;
    
       /* Data lines to LCD now set up - tell it to read them */
       LCD_pulseEnablePin();
    }
    
    /*-------------------------------------------------------------------------*\
    |* HELPER FUNCTION :: LCD_pulseEnablePin
    |*
    |*    This function must be called whenever the LCD needs
    |*    to be told to scan it's data bus.
    |*
    |* PARAMETERS
    |*
    |*    void
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_pulseEnablePin(void)
    {
       /* Pull EN bit low */
       P2DIR &= ~LCD_PIN_EN;
       __delay_cycles(200);
    
       /* Pull EN bit high */
       P2DIR |= LCD_PIN_EN;
       __delay_cycles(200);
    
       /* Pull EN bit low again */
       P2DIR &= ~LCD_PIN_EN;
       __delay_cycles(200);
    }
    
    
    
    /*
     * main.c
     *
     *  Created on: Oct 18, 2012
     *      Author: Stephen Bennett
     */
    
    #include "libLCD.h"
    #include "libMSP430.h"
    
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: main
    |*
    |*    Main entry point to the sketch.
    |*
    |* PARAMETERS
    |*
    |*    void
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void main(void)
    {
       WDTCTL = WDTPW + WDTHOLD;   // Stop watchdog timer
    
       P1DIR |= BIT6;    // Set BIT6 to be an output (green LED)
       P1OUT &= ~BIT6;   // Turn on the green LED
    
       /* Initialize timer for a 2s delay -> interrupt and return to code in active mode */
       MSP430_timerA0Init(1000);
    
       LCD_init();
    
       while (1)
       {
          LCD_clearScreen();
    
          LCD_printStr("Hi...");
          LCD_setCursorPosition(1, 6);
    
          __bis_SR_register(LPM3_bits + GIE);   // Enter LPM3 with General Interrupts Enabled
    
          LCD_printStr("Hello world");
    
          __bis_SR_register(LPM3_bits + GIE);   // Enter LPM3 with General Interrupts Enabled
       }
    }
    
    void timerA0InterruptHandler(void)
    {
       P1OUT ^= BIT6;    // Toggle the green LED for visual cue
    }
    
    
    

  • Hi phanendra,

    Was your project functioning correctly in Energia before attempting to port to IAR? 

    -Chris

  • Quickly scrolling through your code i think you have mixed the P2DIR and P2OUT function.
    Setting the P2DIR in the init is OK but when you would like to write data you may want to use P2OUT to get the data out.
    Note: P2DIR does set the direction of the IO (Input = 0 / Output = 1) while P2OUT sets the level when output is enabled by P2DIR

    Regards,
    Stefan
  • /*
     * libLCD.c
     *
     *  Created on: Oct 18, 2012
     *      Author: Stephen Bennett
     */
    
    #include "lcdLib.h"
    
    
    /******************************\
    |* Helper Function Prototypes *|
    \******************************/
    void LCD_sendCommand(char command);
    void LCD_sendByte(char byteToSend, uint8_t byteType);
    void LCD_sendNibble(char nibbleToSend);
    void LCD_pulseEnablePin(void);
    
    
    /********************\
    |* Public Functions *|
    \********************/
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_setCursorPosition
    |*
    |*    Set the position of the cursor on the screen.
    |*
    |* PARAMETERS
    |*
    |*    ** Does not check row/col limits **
    |*    row - zero based row number < LCD_NUM_ROWS
    |*    col - zero based col number < LCD_NUM_COLS
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_setCursorPosition(uint8_t row, uint8_t col)
    {
       uint8_t address;
    
       /* Construct address from (row, col) pair */
       if (row == 0)
       {
          address = 0;
       }
       else
       {
          address = 0x40;
       }
    
       address |= col;
    
       LCD_sendCommand(0x80 | address);
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_clearScreen
    |*
    |*    Clear the screen data and return the cursor to home position (0, 0).
    |*    Automatically sets the cursor to increment.
    |*    Display shifting is unaffected.
    |*
    |* PARAMETERS
    |*
    |*    void
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_clearScreen(void)
    {
       LCD_sendCommand(CLEAR_DISP_CMD);
       LCD_sendCommand(RET_HOME_CMD);
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_init
    |*
    |*    Initialize the LCD after power-up
    |*
    |* NOTE:
    |*    This routine must not be called twice on the LCD.
    |*    This is not uncommon when the power for the MCU and LCD are separate.
    |*
    |* PARAMETERS
    |*
    |*    void
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_init(void)
    {
       /* Set the MSP pin configurations and bring them LOW */
       P2DIR |= LCD_MASK_DATA;
       P2DIR   |= LCD_PIN_RS;
       P2DIR   |= LCD_PIN_EN;
    
       P2OUT &= ~(LCD_MASK_DATA);
       P2OUT   &= ~LCD_PIN_RS;
       P2OUT   &= ~LCD_PIN_EN;
    
       /* Wait for the LCD to warm up and reach active regions.
        * Remember MSPs can power up much faster than the LCD.
        * (At least 40ms after Vcc rises above 2.7V)
        */
       _delay_milliseconds(80);
    
       /*****************************\
       |* Initialize the LCD module *|
       \*****************************/
       /* According to Hitachi HD44780 datasheet (fig 24, pg 46) */
    
       /* 1a. Set to 4-bit input - try three (3) times */
       uint8_t i = 3;
       while (i != 0)
       {
          LCD_sendNibble(0x03);
          _delay_milliseconds(5);
          --i;
       }
    
       /* 1b. Set to 4-bit interface */
       LCD_sendNibble(0x02);
       _delay_milliseconds(1);
    
       /* 1c. Set number of lines, font size, etc. */
       LCD_sendCommand(FUNCTION_SET_CMD);
       _delay_milliseconds(1);
    
       /* 2. Initialize display
        *    Turn display on/off, cursor on/off, cursor blinking on/off
        */
       LCD_sendCommand(DISPLAY_ON_CMD);
       _delay_milliseconds(1);
    
       /* 3. Initialize entry mode
        *    Text direction, cursor move, display shifting, etc.
        */
       LCD_sendCommand(ENTRY_MODE_CMD);
       _delay_milliseconds(1);
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_printStr
    |*
    |*    Print a string of characters to the screen.
    |*
    |* PARAMETERS
    |*
    |*    text - NULL terminated string of chars
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_printStr(char *text)
    {
       char *c;
       c = text;
    
       while ((c != 0) && (*c != 0))
       {
          LCD_sendByte(*c, DATA);
          c++;
       }
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_printChar
    |*
    |*    Print a character to the screen.
    |*
    |* PARAMETERS
    |*
    |*    character - character to be printed
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_printChar(char character)
    {
       LCD_sendByte(character, DATA);
    }
    
    /*-------------------------------------------------------------------------*\
    |* PUBLIC FUNCTION :: LCD_sendCommand
    |*
    |*    Send a command to the LCD on the data bus in 4 bit mode.
    |*
    |* PARAMETERS
    |*
    |*    command - command to send
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_sendCommand(char command) {
       LCD_sendByte(command, COMMAND);
    }
    
    
    /********************\
    |* Helper Functions *|
    \********************/
    
    /*-------------------------------------------------------------------------*\
    |* HELPER FUNCTION :: LCD_sendByte
    |*
    |*    Send a byte on the data bus in 4 bit mode.
    |*    This requires sending the data in two chunks.
    |*    High nibble first, then low nibble.
    |*
    |* PARAMETERS
    |*
    |*    byteToSend - single byte to send
    |*    byteType   - either DATA or COMMAND
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_sendByte(char byteToSend, uint8_t byteType)
    {
       /* Set Reg Select line to appropriate mode (HIGH: data | LOW: command) */
       if (byteType == COMMAND)
       {
          P2OUT &= ~LCD_PIN_RS;
       }
       else // (byteType == DATA)
       {
          P2OUT |= LCD_PIN_RS;
       }
    
       /* set High Nibble (HN) on data lines */
       LCD_sendNibble( (byteToSend & 0xF0) >> 4);
    
       /* set Low Nibble (LN) on data lines */
       LCD_sendNibble( byteToSend & 0x0F);
    }
    
    /*-------------------------------------------------------------------------*\
    |* HELPER FUNCTION :: LCD_sendNibble
    |*
    |*    Send a nibble on the data bus in 4 bit mode.
    |*
    |* PARAMETERS
    |*
    |*    byteToSend - single byte to send
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_sendNibble(char nibbleToSend)
    {
       /* Clear out all data pins */
       P2OUT &= ~(LCD_MASK_DATA);
    
       /* Set the nibble */
       P2OUT |= nibbleToSend;
    
       /* Data lines to LCD now set up - tell it to read them */
       LCD_pulseEnablePin();
    }
    
    /*-------------------------------------------------------------------------*\
    |* HELPER FUNCTION :: LCD_pulseEnablePin
    |*
    |*    This function must be called whenever the LCD needs
    |*    to be told to scan it's data bus.
    |*
    |* PARAMETERS
    |*
    |*    void
    |*
    |* RETURN
    |*
    |*    void
    |*
    \*-------------------------------------------------------------------------*/
    void LCD_pulseEnablePin(void)
    {
       /* Pull EN bit low */
       P2OUT &= ~LCD_PIN_EN;
       __delay_cycles(200);
    
       /* Pull EN bit high */
       P2OUT |= LCD_PIN_EN;
       __delay_cycles(200);
    
       /* Pull EN bit low again */
       P2OUT &= ~LCD_PIN_EN;
       __delay_cycles(200);
    }
    
    // vim: tabstop=3 expandtab shiftwidth=3 softtabstop=3

    Thanks Stefan,

    i have changed the code as per the suggestion,but still couldn't display any characters on the screen,only i am able to see black dots it self.

  • Hi,

    Please verify ,i am stuck with this code.
  • Hi Phanendra,

    Please provide more information, 

    Are you receiving any error codes in the IDE?

    What debug methods have you tried so far?

    -Chris

  • Hi Chris,

    There are no error debugs in the code.

  • Hi Chris,

    It works now,due to some grounding issue,it hasn't worked.

    The following is the snippet of code.

    unsigned char packetBuf[PACKETLEN];
    unsigned int battVoltage;
    
    packetBuf[106]=battVoltage&0xFF;
    packetBuf[107]=(battVoltage >> 8) & 0xFF;

    ,

    I need your guidance for displaying 8 bit value and pass it through databus on to LCD.

  • Phanendra,

    Glad to hear your display is now working!

    Please review the following Application Report: "Designing with MSP430 MCUs and Segment LCDs".

    This document should contain all the information to consider when designing a segment LCD project with MSP430. 

    Best,

    -Chris

  • Hi

    I need to display the above parameters on LCD,as they are hexadecimal numbers.

    During the conversion i am able to see 8 zeroes on the LCD 16x2 screen.

    Please find the below code snippet for hexadecimal conversion.

     unsigned int hexadecimal_to_decimal(unsigned int value)
     {
        unsigned char a,b,c,d;
        unsigned int e,f,g,decimal;
        a=(value&0x0F); //extract first bit
        
        b=((value>>4)&0x0F); //extract second bit
       
        c=((value>>8)&0x0F); //extract third bit
      
        d=((value>>12)&0x0F); //extract fourth bit
      
        
        e= a*(8>>3);
        f= (b*(8<<1))+e;
        g= (c*(8<<5))+f;
        decimal = (d*(8<<9))+g;
        
        return decimal;
     }

  • Hi Please guide need to complete a project.
  • Phanendra,

    You are seeing numbers on the screen now - correct?
    What is the current issue?

    Have you had time to review the resources linked in this thread - the examples and application report?

    -Chris

**Attention** This is a public forum