LCD instruction

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!

Reply to
Viet Tran
Loading thread data ...

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
Reply to
John Devereux

S); //this is a normal DATA

ATA Line

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

Reply to
linnix

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.

Reply to
Hans-Bernhard Bröker

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

Read the HD44780 datasheet.

Reply to
Jaded Hobo

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.