LCD instruction

Jul 27, 2012 4 Replies

Hi all!



I have a query, i want to consult from your comment !



I have a program to make LCD display this "VIET ELECTRONIC" My code as follow:



#include "MSP430F1121.h" void write_instruction(void) { P2DIR|=0xFF; P2OUT|=BIT2; P2OUT &=~ BIT0; P2OUT &=~ BIT1; P2OUT &=~ BIT2; } void write(char chr){ P2DIR =0xFF; P2OUT |= BIT0; //sbi(CTRL,RS); //this is a normal DATA P1DIR = 0xFF; P1OUT = chr; //out 8 bits to DATA Line P2DIR = 0xFF; P2OUT |= BIT2; P2DIR =0xFF; P2OUT &=~BIT2;//Write8Bit(chr); //wait_LCD(); }



void Data(char* str) { unsigned char i; for (i=0; str[i]!=0; i++) write(str[i]); } int main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; P1DIR=0xFF; P1OUT=0x38; write_instruction(); P1DIR=0xFF; P1OUT=0x0C; write_instruction(); P1DIR=0xFF; P1OUT=0x01; write_instruction(); P1DIR=0xFF; P1OUT=0x80; // the first instruction write_instruction(); Data("VIET"); P1DIR=0xFF; P1OUT=0xC0; // the second instruction write_instruction(); Data("ELECTRONIC");



return 0; }


And in my code, have 2 instruction : CODE: SELECT ALL ...... P1OUT=0x80; // the first instruction ...... P1OUT=0xC0; // the second intruction ......


Can you explain to me that: What do two instruction above mean? What are 2 instruction above used for?



Thank all! Looking for to seeing your comment soon!


In general terms you are changing the state of the port pins each time you do "P1OUT=x", according to the bit pattern of x. Is that what you are asking? The physical effect of this will depend on what port pins are wired to what LCD pins.

John Devereux

S); //this is a normal DATA

ATA Line

And he doesn't need to do PIDIR all the time, just once.

Actually, that's quite clearly _not_ your code. It's somebody else's code you acquired somehow. Because if it were your code by any sensible definition of that term, you wouldn't have to ask those questions about it:

Ask the person you lifted that code from.

Ask the person you lifted that code from.

Since my ISP blocks all original posts and only lets replies trough, this is in reply to the OP.

Read the HD44780 datasheet.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required