EmbeddedRelated.com
Forums

about lcd interfacing

Started by aniket patwardhan December 16, 2008
hello
i am currently working on msp430f1611 and interfacing it with
5V lcd which is of 44780 type in 4 bit mode.I have written the
functions for writing nibbles into mc.I could display the characters
on lcd but the delay placed in between is not working.Please guide me
about time specifications and clock to be used i.e.mclk,smclk. I m
using 32.768 khz crystal.

Thanks
Aniket

Beginning Microcontrollers with the MSP430

You have two clock sources at your disposal.

(1) The LFXT1 crystal controlled oscillator has a fixed frequency
(32768 Hz) and takes a long time (hundreds of milli-sec) to start.

(2) The DCO has variable frequency (~700 kHz to ~5 MHz) and starts
real fast (a few micro-sec). Its frequency is controlled by DCOCTL
register and 3 bits of BCSCTL1 register.

You have three different routes to deliver clock to CPU and peripherals.

(a) ACLK delivers the LFXT1 oscillator divide by 8, 4, 2, or 1. This
is controlled by part of BCSCTL1 register.

(b) SMCLK delivers either the DCO or the LFXT1 oscillator dived by 8,
4, 2, or 1. This is controlled by 3 bits of BCSCTL2 register.

(c) MCLK delivers either the DCO or the LFXT1 oscillator dived by 8,
4, 2, or 1. This is controlled by 4 bits of BCSCTL2 register.

If you use an oscilloscope, you can program P5.6, P5.5, and P5.4 to
see ACLK, SMCLK, and MCLK. (But you cannot see DCO or LFXT1 oscillator
signals directly.) This is controlled by 3 bits of both P5SEL and
P5OUT registers.

--- In m..., "aniket patwardhan"
wrote:
>
> hello
> i am currently working on msp430f1611 and interfacing it with
> 5V lcd which is of 44780 type in 4 bit mode.I have written the
> functions for writing nibbles into mc.I could display the characters
> on lcd but the delay placed in between is not working.Please guide me
> about time specifications and clock to be used i.e.mclk,smclk. I m
> using 32.768 khz crystal.
>
> Thanks
> Aniket
>

You aren't giving enought information about your problem. What is your
problem? Writing nibbles? Writing characters? the delay routine
between WHAT?

Your only concern should be the LCD timing, which doesn't require a
clock signal, so there is no correct MCLK or SMCLK frequency or
setting. The LCD timings can be found on your displays datasheet.

The internet is full of functions and tutorials for driving these
types of displays for almost any type of microcontroller. It is
perhaps the most widely used peripheral you can connect to a uC. Did
you do a google search?

If google can't help you, post the code you are having problems with
and describe what you wanted it to do. Only then can we help you to
resolve your problem instad of guessing what you may be doing and what
you may be having problems with.

Michael K.

--- In m..., "aniket patwardhan"
wrote:
>
> hello
> i am currently working on msp430f1611 and interfacing it with
> 5V lcd which is of 44780 type in 4 bit mode.I have written the
> functions for writing nibbles into mc.I could display the characters
> on lcd but the delay placed in between is not working.Please guide me
> about time specifications and clock to be used i.e.mclk,smclk. I m
> using 32.768 khz crystal.
>
> Thanks
> Aniket
>

I could send text from a MSP430F2012 to the LCD using 4 bit with no problem. The delay between commands or between character was just a simple piece of code of 2 nested for loops. One thing I found was that make sure you follow the initialize sequence, otherwise, sometimes the text shows up correctly, sometimes it doesn't.

-Thanh

--- On Mon, 12/15/08, aniket patwardhan wrote:
From: aniket patwardhan
Subject: [msp430] about lcd interfacing
To: m...
Date: Monday, December 15, 2008, 11:08 PM


hello

i am currently working on msp430f1611 and interfacing it with

5V lcd which is of 44780 type in 4 bit mode.I have written the

functions for writing nibbles into mc.I could display the characters

on lcd but the delay placed in between is not working.Please guide me

about time specifications and clock to be used i.e.mclk,smclk. I m

using 32.768 khz crystal.

Thanks

Aniket















hello

even i could send the data to lcd using 4 bit.my prob is with delay.i
even used nested loops but when i vary the count it is not varying.i m
working with MSP430F1611.Please can you send me your initialization
code.

Aniket

On Sat, Dec 20, 2008 at 7:16 AM, Thanh Tran wrote:
> I could send text from a MSP430F2012 to the LCD using 4 bit with no problem.
> The delay between commands or between character was just a simple piece of
> code of 2 nested for loops. One thing I found was that make sure you follow
> the initialize sequence, otherwise, sometimes the text shows up correctly,
> sometimes it doesn't.
>
> -Thanh
>
> --- On Mon, 12/15/08, aniket patwardhan wrote:
> From: aniket patwardhan
> Subject: [msp430] about lcd interfacing
> To: m...
> Date: Monday, December 15, 2008, 11:08 PM
>
> hello
>
> i am currently working on msp430f1611 and interfacing it with
>
> 5V lcd which is of 44780 type in 4 bit mode.I have written the
>
> functions for writing nibbles into mc.I could display the characters
>
> on lcd but the delay placed in between is not working.Please guide me
>
> about time specifications and clock to be used i.e.mclk,smclk. I m
>
> using 32.768 khz crystal.
>
> Thanks
>
> Aniket
>
>

remember simple delay loops will usually be optimized out.. SO you can change them all you want with little effect.. If the code serves no useful purpose the compiler is free to throw it away..


use the intrinsic function __delay_cycles found in many of the msp430 compilers

__delay_cycles(unsigned long n);


nMUST be a constant, this produces inline code..


if you want to try a loop use __no_operation(void);
within the loop but be warned the loop may get thrown away by the compiler as stated above..

to the compiler these two functionsmay bethe same

void loop(void)
{
;
}

and

void loop2(void)
{
int i;
for(i= 0; i < 11; i++)
{
;// anything in here thats not used outside of this function
}

}

since both functions do not do anything..

--- On Sat, 12/20/08, aniket patwardhan wrote:

From: aniket patwardhan
Subject: Re: [msp430] about lcd interfacing
To: m...
Date: Saturday, December 20, 2008, 2:05 AM

hello

even i could send the data to lcd using 4 bit.my prob is with delay.i
even used nested loops but when i vary the count it is not varying.i m
working with MSP430F1611. Please can you send me your initialization
code.

Aniket

On Sat, Dec 20, 2008 at 7:16 AM, Thanh Tran wrote:
> I could send text from a MSP430F2012 to the LCD using 4 bit with no problem.
> The delay between commands or between character was just a simple piece of
> code of 2 nested for loops. One thing I found was that make sure you follow
> the initialize sequence, otherwise, sometimes the text shows up correctly,
> sometimes it doesn't.
>
> -Thanh
>
> --- On Mon, 12/15/08, aniket patwardhan wrote:
> From: aniket patwardhan
> Subject: [msp430] about lcd interfacing
> To: msp430@yahoogroups. com
> Date: Monday, December 15, 2008, 11:08 PM
>
> hello
>
> i am currently working on msp430f1611 and interfacing it with
>
> 5V lcd which is of 44780 type in 4 bit mode.I have written the
>
> functions for writing nibbles into mc.I could display the characters
>
> on lcd but the delay placed in between is not working.Please guide me
>
> about time specifications and clock to be used i.e.mclk,smclk. I m
>
> using 32.768 khz crystal.
>
> Thanks
>
> Aniket
>
>
>
>



i could manage this all but i think the problem is with clock
initialization.Please tell me is it better to use dco or not?

Aniket

On Sat, Dec 20, 2008 at 1:07 PM, Joe Radomski wrote:
> remember simple delay loops will usually be optimized out.. SO you can
> change them all you want with little effect.. If the code serves no useful
> purpose the compiler is free to throw it away..
> use the intrinsic function __delay_cycles found in many of the msp430
> compilers
>
> __delay_cycles(unsigned long n);
> n MUST be a constant, this produces inline code..
> if you want to try a loop use __no_operation(void);
> within the loop but be warned the loop may get thrown away by the compiler
> as stated above..
>
> to the compiler these two functions may be the same
>
> void loop(void)
> {
> ;
> }
>
> and
>
> void loop2(void)
> {
> int i;
> for(i= 0; i < 11; i++)
> {
> ;// anything in here thats not used outside of this function
> }
>
> }
>
> since both functions do not do anything..
>
> --- On Sat, 12/20/08, aniket patwardhan wrote:
>
> From: aniket patwardhan
> Subject: Re: [msp430] about lcd interfacing
> To: m...
> Date: Saturday, December 20, 2008, 2:05 AM
>
> hello
>
> even i could send the data to lcd using 4 bit.my prob is with delay.i
> even used nested loops but when i vary the count it is not varying.i m
> working with MSP430F1611. Please can you send me your initialization
> code.
>
> Aniket
>
> On Sat, Dec 20, 2008 at 7:16 AM, Thanh Tran wrote:
>> I could send text from a MSP430F2012 to the LCD using 4 bit with no
>> problem.
>> The delay between commands or between character was just a simple piece of
>> code of 2 nested for loops. One thing I found was that make sure you
>> follow
>> the initialize sequence, otherwise, sometimes the text shows up correctly,
>> sometimes it doesn't.
>>
>> -Thanh
>>
>> --- On Mon, 12/15/08, aniket patwardhan
>> wrote:
>> From: aniket patwardhan
>> Subject: [msp430] about lcd interfacing
>> To: msp430@yahoogroups. com
>> Date: Monday, December 15, 2008, 11:08 PM
>>
>> hello
>>
>> i am currently working on msp430f1611 and interfacing it with
>>
>> 5V lcd which is of 44780 type in 4 bit mode.I have written the
>>
>> functions for writing nibbles into mc.I could display the characters
>>
>> on lcd but the delay placed in between is not working.Please guide me
>>
>> about time specifications and clock to be used i.e.mclk,smclk. I m
>>
>> using 32.768 khz crystal.
>>
>> Thanks
>>
>> Aniket
>>
>>
>

Are you using c? If so, the count may have evaporated and you get no
delay at all.

Make it volatile, then perhaps it will not evaporate.

--OCY

--- "aniket patwardhan" wrote:
>
> hello
>
> even i could send the data to lcd using 4 bit.my prob is
> with delay.i even used nested loops but when i vary the
> count it is not varying.i m working with MSP430F1611.
> Please can you send me your initialization code.
>
> Aniket
>

most lcds are quite forgiving so an exact delay is not necessary, its usually important to meet the minimum delays required for each command..

I've never had any problems using the dco...

You should really measure the timings of your pulses.. invest in a logic analyzer even a cheap one.. fors simple MC development.. something like this will work..

http://www.sparkfun.com/commerce/product_info.php?products_id=8938

the oly thing to watch out for is that the v high is not adjustable, so your VCC has to be set so that at a minimum 2.0v is high.. if you keep the current on any individual output to about 4ma or less 2.2v is about the safe miniimum.. more current than this and you need to bump up the voltage..



--- On Sat, 12/20/08, aniket patwardhan wrote:

From: aniket patwardhan
Subject: Re: [msp430] about lcd interfacing
To: m...
Date: Saturday, December 20, 2008, 2:42 AM

i could manage this all but i think the problem is with clock
initialization. Please tell me is it better to use dco or not?

Aniket

On Sat, Dec 20, 2008 at 1:07 PM, Joe Radomski wrote:
> remember simple delay loops will usually be optimized out.. SO you can
> change them all you want with little effect.. If the code serves no useful
> purpose the compiler is free to throw it away..
> use the intrinsic function __delay_cycles found in many of the msp430
> compilers
>
> __delay_cycles( unsigned long n);
> n MUST be a constant, this produces inline code..
> if you want to try a loop use __no_operation( void);
> within the loop but be warned the loop may get thrown away by the compiler
> as stated above..
>
> to the compiler these two functions may be the same
>
> void loop(void)
> {
> ;
> }
>
> and
>
> void loop2(void)
> {
> int i;
> for(i= 0; i < 11; i++)
> {
> ;// anything in here thats not used outside of this function
> }
>
> }
>
> since both functions do not do anything..
>
> --- On Sat, 12/20/08, aniket patwardhan wrote:
>
> From: aniket patwardhan
> Subject: Re: [msp430] about lcd interfacing
> To: msp430@yahoogroups. com
> Date: Saturday, December 20, 2008, 2:05 AM
>
> hello
>
> even i could send the data to lcd using 4 bit.my prob is with delay.i
> even used nested loops but when i vary the count it is not varying.i m
> working with MSP430F1611. Please can you send me your initialization
> code.
>
> Aniket
>
> On Sat, Dec 20, 2008 at 7:16 AM, Thanh Tran wrote:
>> I could send text from a MSP430F2012 to the LCD using 4 bit with no
>> problem.
>> The delay between commands or between character was just a simple piece of
>> code of 2 nested for loops. One thing I found was that make sure you
>> follow
>> the initialize sequence, otherwise, sometimes the text shows up correctly,
>> sometimes it doesn't.
>>
>> -Thanh
>>
>> --- On Mon, 12/15/08, aniket patwardhan
>> wrote:
>> From: aniket patwardhan
>> Subject: [msp430] about lcd interfacing
>> To: msp430@yahoogroups. com
>> Date: Monday, December 15, 2008, 11:08 PM
>>
>> hello
>>
>> i am currently working on msp430f1611 and interfacing it with
>>
>> 5V lcd which is of 44780 type in 4 bit mode.I have written the
>>
>> functions for writing nibbles into mc.I could display the characters
>>
>> on lcd but the delay placed in between is not working.Please guide me
>>
>> about time specifications and clock to be used i.e.mclk,smclk. I m
>>
>> using 32.768 khz crystal.
>>
>> Thanks
>>
>> Aniket
>>
>>
>
>
>



Joe,

I think Aniket does not have a problem between his MSP430 and the LCD
unit. His problem is between the LCD and his eyes. A sequence of LCD
images goes by and he cannot read but the individual frames.

He tried to put delay loops in between frames, but the compiler
optimized the delay loops out.

-- OCY

--- In m..., Joe Radomski wrote:
>
> most lcds are quite forgiving so an exact delay is not necessary,
its usually important to meet the minimum delays required for each
command..
>
> I've never had any problems using the dco...
>
> You should really measure the timings of your pulses.. invest in a
logic analyzer even a cheap one.. fors simple MC development..
something like this will work..
>
> http://www.sparkfun.com/commerce/product_info.php?products_id38
>
> the oly thing to watch out for is that the v high is not adjustable,
so your VCC has to be set so that at a minimum 2.0v is high.. if you
keep the current on any individual output to about 4ma or less 2.2v is
about the safe miniimum.. more current than this and you need to bump
up the voltage..
>
>
>
> --- On Sat, 12/20/08, aniket patwardhan wrote:
>
> From: aniket patwardhan
> Subject: Re: [msp430] about lcd interfacing
> To: m...
> Date: Saturday, December 20, 2008, 2:42 AM
> i could manage this all but i think the problem is with clock
> initialization. Please tell me is it better to use dco or not?
>
> Aniket
>
> On Sat, Dec 20, 2008 at 1:07 PM, Joe Radomski
yahoo.com> wrote:
> > remember simple delay loops will usually be optimized out.. SO you can
> > change them all you want with little effect.. If the code serves
no useful
> > purpose the compiler is free to throw it away..
> >
> >
> > use the intrinsic function __delay_cycles found in many of the msp430
> > compilers
> >
> > __delay_cycles( unsigned long n);
> >
> >
> > n MUST be a constant, this produces inline code..
> >
> >
> > if you want to try a loop use __no_operation( void);
> > within the loop but be warned the loop may get thrown away by the
compiler
> > as stated above..
> >
> > to the compiler these two functions may be the same
> >
> > void loop(void)
> > {
> > ;
> > }
> >
> > and
> >
> > void loop2(void)
> > {
> > int i;
> > for(i= 0; i < 11; i++)
> > {
> > ;// anything in here thats not used outside of this function
> > }
> >
> > }
> >
> > since both functions do not do anything..
> >
> > --- On Sat, 12/20/08, aniket patwardhan
gmail.com> wrote:
> >
> > From: aniket patwardhan
> > Subject: Re: [msp430] about lcd interfacing
> > To: msp430@yahoogroups. com
> > Date: Saturday, December 20, 2008, 2:05 AM
> >
> > hello
> >
> > even i could send the data to lcd using 4 bit.my prob is with delay.i
> > even used nested loops but when i vary the count it is not varying.i m
> > working with MSP430F1611. Please can you send me your initialization
> > code.
> >
> > Aniket
> >
> > On Sat, Dec 20, 2008 at 7:16 AM, Thanh Tran
yahoo.com> wrote:
> >> I could send text from a MSP430F2012 to the LCD using 4 bit with no
> >> problem.
> >> The delay between commands or between character was just a simple
piece of
> >> code of 2 nested for loops. One thing I found was that make sure you
> >> follow
> >> the initialize sequence, otherwise, sometimes the text shows up
correctly,
> >> sometimes it doesn't.
> >>
> >> -Thanh
> >>
> >> --- On Mon, 12/15/08, aniket patwardhan
> >> wrote:
> >> From: aniket patwardhan
> >> Subject: [msp430] about lcd interfacing
> >> To: msp430@yahoogroups. com
> >> Date: Monday, December 15, 2008, 11:08 PM
> >>
> >> hello
> >>
> >> i am currently working on msp430f1611 and interfacing it with
> >>
> >> 5V lcd which is of 44780 type in 4 bit mode.I have written the
> >>
> >> functions for writing nibbles into mc.I could display the characters
> >>
> >> on lcd but the delay placed in between is not working.Please guide me
> >>
> >> about time specifications and clock to be used i.e.mclk,smclk. I m
> >>
> >> using 32.768 khz crystal.
> >>
> >> Thanks
> >>
> >> Aniket
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
>
>
>
>