There are 5 messages in this thread.
You are currently looking at messages 1 to 5.
So far in June, you have voted 0 times ou of a total of 16 votes by the community.
Please help us clean the archives from unuseful discussion threads by using the voting system! Details here.
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!
Viet Tran <q...@gmail.com> writes:
> 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
On Jul 27, 4:06 am, John Devereux <j...@devereux.me.uk> wrote:
> Viet Tran <quocviet.d...@gmail.com> writes:
> > 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.
>
And he doesn't need to do PIDIR all the time, just once.
On 27.07.2012 08:41, Viet Tran wrote: > My code as follow: 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: > What do two instruction above mean? Ask the person you lifted that code from. > What are 2 instruction above used for? Ask the person you lifted that code from.
On Fri, 27 Jul 2012 12:06:51 +0100, John Devereux wrote:
> Viet Tran <q...@gmail.com> writes:
>
>> 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.
Since my ISP blocks all original posts and only lets replies trough, this
is in reply to the OP.
Read the HD44780 datasheet.