Felipe 0 Posted May 5, 2012 Share Posted May 5, 2012 I'm trying to initialize the LCD but I'm in trouble, he gets the first line all connected and not write anything. My LCD is MGD1602-FL and this is my code // // MSP430 LCD Code // #include "msp430.h" #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 BIT4 // P1.0 #define LCM_PIN_EN BIT5 // P1.1 #define LCM_PIN_D7 BIT0 // P1.7 #define LCM_PIN_D6 BIT1 // P1.6 #define LCM_PIN_D5 BIT2 // P1.5 #define LCM_PIN_D4 BIT3 // 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(100000); // // initialize the LCM module // // 1. Set 4-bit input // LCM_OUT &= ~LCM_PIN_RS; LCM_OUT &= ~LCM_PIN_EN; LCM_OUT = 0x20; PulseLcm(); // // set 4-bit input - second time. // (as reqd by the spec.) // SendByte(0x38, FALSE); // // 2. Display on, cursor on, blink cursor // SendByte(0x0F, FALSE); // // 3. Cursor move auto-increment // SendByte(0x06, FALSE); } // // 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); c++; } } // // Routine Desc // // main entry point to the sketch // // Parameters // // void. // // Returns // // void. // but does not work, I think the same is prioblema at startup. Can anyone help me? Quote Link to post Share on other sites
SugarAddict 227 Posted May 6, 2012 Share Posted May 6, 2012 try // // initialize the LCM module // // 1. Set 4-bit input // LCM_OUT &= ~LCM_PIN_RS; LCM_OUT &= ~LCM_PIN_EN; LCM_OUT = 0x28; PulseLcm(); // // set 4-bit input - second time. // (as reqd by the spec.) // SendByte(0x28, FALSE); // // 2. Display on, cursor on, blink cursor // SendByte(0x0F, FALSE); // // 3. Cursor move auto-increment // SendByte(0x04, FALSE); http://www.datsi.fi.upm.es/docencia/Mic ... s0066u.pdf Quote Link to post Share on other sites
Felipe 0 Posted May 7, 2012 Author Share Posted May 7, 2012 look how stay my lcd imageshack. us/photo/my-images/135/dsc05376t.jpg Quote Link to post Share on other sites
jim940 28 Posted May 7, 2012 Share Posted May 7, 2012 Might be a issue of using a 5V LCD with the 3.6V Launch Pad. Also ... check to make sure the GND of the LCD and the GND of the LaunchPad are connected together. Jim Quote Link to post Share on other sites
Felipe 0 Posted May 7, 2012 Author Share Posted May 7, 2012 They are not connected together, the launchpad is connected to the PC and the LCD is on the protoboard Quote Link to post Share on other sites
jim940 28 Posted May 7, 2012 Share Posted May 7, 2012 I'm pretty sure, the GNDs need to be connected so the LCD and LaunchPad agree what the voltage levels are. Jim Quote Link to post Share on other sites
Felipe 0 Posted May 7, 2012 Author Share Posted May 7, 2012 I put the pin GND of launchpad in the GND of protoboard, but still don Quote Link to post Share on other sites
jim940 28 Posted May 7, 2012 Share Posted May 7, 2012 It might not be, because the LCD wants 5V but the LaunchPad is only 3.6V barely enough to make a proper logical "1" signal. This will work with the LaunchPad http://www.ebay.com/itm/Character-LCD-M ... 4cf98350dd Jim Quote Link to post Share on other sites
cubeberg 540 Posted May 7, 2012 Share Posted May 7, 2012 I've used a 5v couple of HD44780 compatible LCD with the LP without level shifting. I used this diagram and code as a starting point (just make sure to look at the 2nd diagram for wiring, not the first). One thing you might try - if you just plug in 5v & ground, do you get solid blocks on the first line? It could be a contrast issue - I have a 4x20 LCD that requires a negative contrast. If you're not seeing anything with just power applied, that could be your issue. Quote Link to post Share on other sites
Felipe 0 Posted May 8, 2012 Author Share Posted May 8, 2012 Don't work, i think my lcd spoiled i will change them Quote Link to post Share on other sites
Felipe 0 Posted May 8, 2012 Author Share Posted May 8, 2012 My LCD is crazy hahaha. look like my LCD is now I inicilizate and print CEFET, he look like this imageshack.us /photo/my-images/600/dsc05378kj.jpg/ Quote Link to post Share on other sites
bluehash 1,581 Posted May 8, 2012 Share Posted May 8, 2012 Hi Felipe, Could you upload your photo to the 43oh forum server. Imageshack links expire and many people are not able to see imageshack links at work as they are blocked( including me ) Quote Link to post Share on other sites
Felipe 0 Posted May 8, 2012 Author Share Posted May 8, 2012 then.... Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.