• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » MSP430™ Microcontrollers » MSP430 Ultra-Low Power 16-bit Microcontroller Forum » Lcd interfacing problems with msp430f2132.
Share
MSP430™ Microcontrollers
  • Forum
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
MSP430 Resources
  • MSP430 Product Folder
  • MSP-EXP430G2 - MSP430 LaunchPad Value Line Development kit
  • MSP430 Getting Started Guide
  • MSP430 Microcontroller Projects
  • More Resources >
  • Lcd interfacing problems with msp430f2132.

    Lcd interfacing problems with msp430f2132.

    • haridini belan
      Posted by haridini belan
      on Apr 07 2012 04:29 AM
      Prodigy30 points

      I am interfacing  Lcd to msp430f2132.Lcd display facing problem with garbage value.what changes should i do  in this code.please help me.

      #include  "msp430f2132.h"
      unsigned int i;
      #define    LCM_DIR         P1DIR
      #define    LCM_OUT         P1OUT


      //
      // Define symbolic LCM - MCU pin mappings
      // We've set DATA PIN TO 4,5,6,7 for easy translation
      //
      #define     LCM_PIN_RS            BIT5          // p2.5
      #define     LCM_PIN_EN            BIT6             // P2.6
      #define     LCM_PIN_D7            BIT7          // P1.7
      #define     LCM_PIN_D6            BIT6          // P1.6
      #define     LCM_PIN_D5            BIT5          // P1.5
      #define     LCM_PIN_D4            BIT4          // P1.4


      #define     LCM_PIN_MASK  ((LCM_PIN_RS | LCM_PIN_EN | LCM_PIN_D7 | LCM_PIN_D6 | LCM_PIN_D5 | LCM_PIN_D4))

      #define     FALSE                 0
      #define     TRUE                  1

      //
      // Routine Desc:
      //
      // This is the function that must be called
      // whenever the LCM needs to be told to
      // scan it's data bus.
      //
      // Parameters:
      //
      //     void.
      //
      // Return
      //
      //     void.
      //
      void PulseLcm()
      {
          //
          // pull EN bit low
          //
          LCM_OUT &= ~LCM_PIN_EN;
          __delay_cycles(200);

          //
          // pull EN bit high
          //
          LCM_OUT |= LCM_PIN_EN;
          __delay_cycles(200);

          //
          // pull EN bit low again
          //
          LCM_OUT &= (~LCM_PIN_EN);
          __delay_cycles(200);
      }



      //
      // Routine Desc:
      //
      // Send a byte on the data bus in the 4 bit mode
      // This requires sending the data in two chunks.
      // The high nibble first and then the low nible
      //
      // Parameters:
      //
      //    ByteToSend - the single byte to send
      //
      //    IsData - set to TRUE if the byte is character data
      //                  FALSE if its a command
      //
      // Return
      //
      //     void.
      //
      void SendByte(char ByteToSend, int IsData)
      {
          //
          // clear out all pins
          //
          LCM_OUT &= (~LCM_PIN_MASK);
          //
          // set High Nibble (HN) -
          // usefulness of the identity mapping
          // apparent here. We can set the
          // DB7 - DB4 just by setting P1.7 - P1.4
          // using a simple assignment
          //
          LCM_OUT |= (ByteToSend & 0xF0);
       
          if (IsData == TRUE)
          {
              LCM_OUT |= LCM_PIN_RS;
          }
          else
          {
              LCM_OUT &= ~LCM_PIN_RS;
          }
       
          //
          // we've set up the input voltages to the LCM.
          // Now tell it to read them.
          //
          PulseLcm();
           //
          // set Low Nibble (LN) -
          // usefulness of the identity mapping
          // apparent here. We can set the
          // DB7 - DB4 just by setting P1.7 - P1.4
          // using a simple assignment
          //
          LCM_OUT &= (~LCM_PIN_MASK);
          LCM_OUT |= ((ByteToSend & 0x0F) << 4);

          if (IsData == TRUE)
          {
              LCM_OUT |= LCM_PIN_RS;
          }
          else
          {
              LCM_OUT &= ~LCM_PIN_RS;
          }

          //
          // we've set up the input voltages to the LCM.
          // Now tell it to read them.
          //
          PulseLcm();
      }


      //
      // Routine Desc:
      //
      // Set the position of the cursor on the screen
      //
      // Parameters:
      //
      //     Row - zero based row number
      //
      //     Col - zero based col number
      //
      // Return
      //
      //     void.
      //
      void LcmSetCursorPosition(char Row, char Col)
      {
          char address;

          //
          // construct address from (Row, Col) pair
          //
          if (Row == 0)
          {
              address = 0;
          }
          else
          {
              address = 0x40;
          }

          address |= Col;

          SendByte(0x80 | address, FALSE);
      }


      //
      // Routine Desc:
      //
      // Clear the screen data and return the
      // cursor to home position
      //
      // Parameters:
      //
      //    void.
      //
      // Return
      //
      //     void.
      //
      void ClearLcmScreen()
      {
          //
          // Clear display, return home
          //
          SendByte(0x01, FALSE);
          SendByte(0x02, FALSE);
      }


      //
      // Routine Desc:
      //
      // Initialize the LCM after power-up.
      //
      // Note: This routine must not be called twice on the
      //           LCM. This is not so uncommon when the power
      //           for the MCU and LCM are separate.
      //
      // Parameters:
      //
      //    void.
      //
      // Return
      //
      //     void.
      //
      void InitializeLcm(void)
      {
          //
          // set the MSP pin configurations
          // and bring them to low
          //
          LCM_DIR |= LCM_PIN_MASK;
          LCM_OUT &= ~(LCM_PIN_MASK);


          //
          // wait for the LCM to warm up and reach
          // active regions. Remember MSPs can power
          // up much faster than the LCM.
          //
          //__delay_cycles(1000000);

          
          //
          // initialize the LCM module
          //
          // 1. Set 4-bit input
          //
          LCM_OUT &= ~LCM_PIN_RS;
          __delay_cycles(5000);
          LCM_OUT &= ~LCM_PIN_EN;
           __delay_cycles(5000);

          LCM_OUT = 0x20;
          __delay_cycles(5000);
          PulseLcm();
           __delay_cycles(5000);

          //
          // set 4-bit input - second time.
          // (as reqd by the spec.)
          //
          SendByte(0x28, FALSE);
           __delay_cycles(5000);

          //
          // 2. Display on, cursor on, blink cursor
          //
          SendByte(0x0E, FALSE);
           __delay_cycles(5000);
          
          //
          // 3. Cursor move auto-increment
          //
          SendByte(0x06, FALSE);
           __delay_cycles(5000);
      }


      //
      // Routine Desc
      //
      // Print a string of characters to the screen
      //
      // Parameters:
      //
      //    Text - null terminated string of chars
      //
      // Returns
      //
      //     void.
      //
      void PrintStr(char *Text)
      {
          char *c;

          c = Text;

          while ((c != 0) && (*c != 0))
          {
              SendByte(*c, TRUE);
               __delay_cycles(5000);
              c++;
          }
      }


      //
      // Routine Desc
      //
      // main entry point to the sketch
      //
      // Parameters
      //
      //     void.
      //
      // Returns
      //
      //     void.
      //
      void main(void)
      {
          WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer
          DCOCTL=CAL_DCO_1MHZ ;         
          BCSCTL1=CAL_BC1_1MHZ ;
        P2DIR |=0xA0;
          P2OUT|=0xA0;
          for(;;)
          {
          InitializeLcm();

          ClearLcmScreen();
          
           PrintStr("H!");
          
          i = 50000;                              // Delay
          do (i--);
          while (i != 0);

      }
      }


      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andy Neil
      Posted by Andy Neil
      on Apr 07 2012 05:24 AM
      Guru31975 points

      haridini belan
      facing problem with garbage value.what changes should i do  in this code.please help me.

      Before you jump in and start changing stuff, you need to work out why you are getting "garbage".

      This is called debugging - and is an essential part of any form of development.

      Once you know out why you are getting "garbage", it should be clear what you need to change in order to correct the problem(s)!

      If you just make random changes whithout knowing why you are getting "garbage", you will not know if you have actually fixed the underlying problem(s) - or just masked the symptoms...

      So, the first thing you need to check is that your code actually produces signals to the LCD that are fully in conformance with the LCD's specifications. You should pay particular attention to timing...

      Here's some debugging tips to get you started:

      http://www.8052.com/faqs/120313

      http://www.eetimes.com/discussion/break-point/4027526/Developing-a-good-bedside-manner?pageNumber=0

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • haridini belan
      Posted by haridini belan
      on Apr 07 2012 06:41 AM
      Prodigy30 points

      thank you

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use