Searching \ for '[EE]: LCD Initialization and Usage Sequence?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/lcds.htm?key=lcd
Search entire site for: 'LCD Initialization and Usage Sequence?'.

Exact match. Not showing close matches.
PICList Thread
'[EE]: LCD Initialization and Usage Sequence?'
2002\12\05@021603 by Peter McNulty

picon face
Hi,

Could someone give me an idea of what I have to do for LCD initialization, and writing using the HD44780 LCD controller? I'll be using a 20*2 character LCD from crystalfontz.com for my project, and I don't know how to use this controller. I know there is already lots of code for this, however, i need to write this code myself as part of the project specification, and I find it hard to read other peoples code.

The datasheet doesn't give much information, so could someone run throught he steps needed to get this working. According to the datasheet it should go:

LCD Initialize:
Power on -> Wait 15ms -> Send Function set -> Wait 5ms -> Send Function Set -> Wait 100micros  -> Send Function set -> Wait 50micros -> Send Function Set -> wait 50micros  -> Send Display Off -> wait 50Micros -> Send Clear Display -> Wait 2ms  -> Set Entry Mode -> wait 50 Micros -> Finish

But, it's it a bit weird that function set is being set 4 times, and I've never seen this in the code before. I've never seen so many waits in the code before either.

As for the writing to the LCD, it only gives a little image which doesn't help at all. Also, it says send the E pulse or something. Is this simply, on for 1 clock cycle, off for 1 clock cycle  on the E line? Also,  for the write sequence, do i just send the data over DB0-7 or do i have to do something else with RS and R/W. I know the E pulse has to be sent when sending but that's it.

I'll be using PIC18F452 at 20Mhz for this in case that make a difference.

Thanks
-Peter

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@025142 by Brendan Colven

picon face
----- Original Message -----
From: Peter McNulty <spam_OUTpetermcnultyTakeThisOuTspamHOTMAIL.COM>
To: <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU>
Sent: Thursday, December 05, 2002 2:17 AM
Subject: [EE]: LCD Initialization and Usage Sequence?


Hi,

....snip....
The datasheet doesn't give much information, so could someone run throught
he steps needed to get this working. According to the datasheet it should
go:

LCD Initialize:
Power on -> Wait 15ms -> Send Function set -> Wait 5ms -> Send Function
Set -> Wait 100micros  -> Send Function set -> Wait 50micros -> Send
Function Set -> wait 50micros  -> Send Display Off -> wait 50Micros -> Send
Clear Display -> Wait 2ms  -> Set Entry Mode -> wait 50 Micros -> Finish

But, it's it a bit weird that function set is being set 4 times, and I've
never seen this in the code before. I've never seen so many waits in the
code before either.

As for the writing to the LCD, it only gives a little image which doesn't
help at all. Also, it says send the E pulse or something. Is this simply, on
for 1 clock cycle, off for 1 clock cycle  on the E line? Also,  for the
write sequence, do i just send the data over DB0-7 or do i have to do
something else with RS and R/W. I know the E pulse has to be sent when
sending but that's it.
...snip....
Thanks
-Peter

Hi, the weird repetition maybe a result of the mode your controlling the LCD
with.  I know in 4-bit mode (usually uses DB4-7) you have to repeat codes to
send to the LCD.  Are you using 8bit (DB0:7)? 4bit? serial (doesn't sound
like it)?  The E line is used to 'clock' in your data on the data lines.  It
gives you time to setup what you want to send to the LCD on the data lines
then when your code toggles the E line the LCD grabs what is waiting at the
data lines.  I'm not sure how long the E pulse should last, a data sheet for
the HD44780 should say.  I use LCDs that have KS0066U controllers.  It says
to pulse for 450ns.  So a few 'nop's in your code should do the trick.

If your just worried about writting to the LCD and not reading, then you can
ground the R/W line.  This simplifies things.  The RS line is used to tell
the LCD that the value you place on the data lines is either to be used as a
command or as data to display on the screen.  It should only go high when
you want to display data.  During the initilization it should be at 0.

Hope it helps.
Brendan

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@032213 by Peter McNulty

picon face
Hi,

Thanks for the reply. Checking out the data sheet again, it should be 500ns
(0.0000005s) which at 20Mhz, 1 clock takes 50ns so I should do a delay of
10clock cycles right? But, turning ON OFF would take 1 instruction I guess
which would take 4 clock cycles?!?! so, this shortens the delay time right?

Also, for the writing, I send the E pulse, and set the data I want to send
on RB0-7 and thats it I guess, with R/W grounded and RS positive.

I'm using 8 bit mode, it gives and example of 4 bits, which requires the
function set many times also . Maybe it's just the way the controller likes
it then.

-Peter
{Original Message removed}

2002\12\05@055542 by Jinx

face picon face
> initialization, and writing using the HD44780 LCD controller?

> the datasheet it should go:

> LCD Initialize:
> Power on -> Wait 15ms -> Send Function set -> Wait 5ms ->
> Send Function Set -> Wait 100micros  -> Send Function set ->
> Wait 50micros -> Send Function Set -> wait 50micros  -> Send
> Display Off -> wait 50Micros -> Send Clear Display -> Wait 2ms
> -> Set Entry Mode -> wait 50 Micros -> Finish

> But, it's it a bit weird that function set is being set 4 times, and I've
> never seen this in the code before. I've never seen so many waits
> in the code before either.

The sequence I've found to work with every HD44780 LCD for the
way I set them up is -

Power On, delay 15ms, write 0x30, delay 5ms, write 0x30, delay 200us,
write 0x30, delay 200us, write 0x38, write 0x0c, write 0x01, write 0x06

A couple of dozen lines of code in routines are all that's needed to
write data, change adddress, check Busy etc

> says send the E pulse or something. Is this simply, on for 1 clock
> cycle, off for 1 clock cycle  on the E line?

write_d   bsf    rs                  ;RS=1 (for data,  RS=0 for command)
              movwf  portd         ;8-bit data on Portd
              bcf    rw                 ;do a write
              nop                        ;if rw in same port as en (r-m-w)
              bsf    en                 ;move data into 44780
              nop                        ;(r-m-w)
              bcf    en                 ;

> Also,  for the write sequence, do i just send the data over DB0-7 or do
> i have to do something else with RS and R/W. I know the E pulse has
> to be sent when sending but that's it.

See above example. Timing diagram for HD44780 will be helpful to
start, but you only need to get the timing and sequences right once.
After that mostly you'd use it for looking up the character set, learning
how to make redefined characters, change screen options and so on

> I'll be using PIC18F452 at 20Mhz for this in case that make a difference

Only to delay routines

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@061343 by Peter McNulty

picon face
Hi,

Thanks for the information. I wrote a little bit of the program to do the
initialize and it looks like your basically. I guess you are using a 1 line
LCD in yours. I think I've almost got this working, unfortunately I can't
actually test it until some solder arrives so I can solder some wires to the
LCD.

Another question though. Is there any relationship between the character
patterns and say Ascii, or BCD or anything? I'm trying hard to find a
pattern. However, I don't really have a problem simply writing in the binary
value in the source as I'll have static characters except for the numbers.
The number are quite easy as it's just binary for 0-9 and 4 extra bits.

-Peter
{Original Message removed}

2002\12\05@064955 by Jinx

face picon face
> Another question though. Is there any relationship between the
> character patterns and say Ascii, or BCD or anything? I'm trying
> hard to find a pattern.

Not sure what you mean, but characters can be requested by
their ASCII value. eg if you wrote the data '0' or 'z' then that's
what the display will show. 8 characters (ASCII 00 to 07) are
redefinable to other shapes, and you select those for display
by sending a number 0 to 7

> However, I don't really have a problem simply writing in the
> binary value in the source as I'll have static characters except
> for the numbers. The number are quite easy as it's just binary
> for 0-9 and 4 extra bits

As above, send the ASCII value of the number to display it. If
you had the values 0x01, 0x03 and 0x08 in 3 RAM bytes, add
30h to each to convert them to ASCII eg

movlw 0x30
addwf ram1,f
call  lcdwrite        ;where you put it on the data buss and strobe EN
                            ;not changing W, or you'll have to reload it
with 0x30
addwf 0x30
call  lcdwrite
addwf ram3,f
call  lcdwrite

and the display would show "138"

You can get the 44780 datasheet here (390kB)

http://www.eio.com/datashet.htm

and here are some more resources, including EPE's tutorial

http://www.doc.ic.ac.uk/~ih/doc/lcd/

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@065905 by David Duffy

flavicon
face
Peter:
>Thanks for the information. I wrote a little bit of the program to do the
>initialize and it looks like your basically. I guess you are using a 1 line
>LCD in yours. I think I've almost got this working, unfortunately I can't
>actually test it until some solder arrives so I can solder some wires to the
>LCD.
>
>Another question though. Is there any relationship between the character
>patterns and say Ascii, or BCD or anything? I'm trying hard to find a
>pattern. However, I don't really have a problem simply writing in the binary
>value in the source as I'll have static characters except for the numbers.
>The number are quite easy as it's just binary for 0-9 and 4 extra bits.

You can hard code it like this:

(set cursor position first)
        movlw   'H'
        call    lcd_char
        movlw   'e'
        call    lcd_char
        movlw   'l'
        call    lcd_char
        movlw   'l'
        call    lcd_char
        movlw   'o'
        call    lcd_char

The lcd_char routine does something like:

lcd_char:                       ;
        movwf   port_b          ;setup the lcd data
        nop                     ;wait for data lines
        nop                     ;to stabilise then
        bsf     lcd_e           ;strobe the lcd e
        call    delay_500us     ;line for 500us
        bcf     lcd_e           ;
        return                  ;

Hope this helps...

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@074626 by Jinx

face picon face
>          bsf     lcd_e           ;strobe the lcd e
>          call    delay_500us     ;line for 500us
>          bcf     lcd_e           ;

You can strobe EN down to 450ns. For a 20MHz PIC this is
bsf en  nop  bcf en. Another tip for saving time if you need
to is how you work the Busy flag. You can check Busy before
you attempt a write. If the LCD isn't ready, go off and do
something else, maybe prepare data. Typically the LCD takes
40us after a data write to be ready for the next. In one app I
have, the LCD is refreshed during reception of 36400 baud
serial data. While the RX buffer is filling up there's plenty of
time to process and write previously receieved data to the LCD

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@103034 by Bob Ammerman

picon face
If you look at the bit patterns, the extra "Set Function" commands are used
to ensure that the display controller sees at least the last one properly,
regardless of its initial state.

Basically there are 3 states the controller can be in:

1: Waiting for a byte in 8 bit mode
2: Waiting for the first nybble of a byte in 4 bit mode
3: Waiting for the second nybble of a byte in 4 bit mode

Check the datasheet to see what happens when you start in each states and
then perform the multiple "Set Function".

You will find you always end up in the correct state of the 3 above, ready
to get to work.

Bob Ammerman
RAm Systems

{Original Message removed}

2002\12\05@105549 by M. Adam Davis

flavicon
face
Just to be absolutely clear:

Peter McNulty wrote:

>Also, for the writing, I send the E pulse, and set the data I want to send
>on RB0-7 and thats it I guess, with R/W grounded and RS positive.
>
>
You do *not* send the E pulse before the data.

You put the data on the lines, then bring E high, then bring E low, then
put the next data on the lines.

In all cases, the byte that is loaded on the LCD is whatever was on the
lines when the E line goes from low to high.  If you bring it high
before you load the data, you'll be putting the previous data on the line.

I hope this helps...

-Adam

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@110322 by Bob Ammerman

picon face
----- Original Message -----
From: "Jinx" <joecolquittspamKILLspamCLEAR.NET.NZ>
To: <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>
Sent: Thursday, December 05, 2002 7:44 AM
Subject: Re: [EE]: LCD Initialization and Usage Sequence?


> >          bsf     lcd_e           ;strobe the lcd e
> >          call    delay_500us     ;line for 500us
> >          bcf     lcd_e           ;
>
> You can strobe EN down to 450ns. For a 20MHz PIC this is
> bsf en  nop  bcf en.


Er....

   bsf    en
   nop
   bcf    en

gives you only 400ns wide en pulse on a 20MHz PIC.

you'll need

   bsf    en
   nop
   nop
   bcf    en

to be safe (at 600ns pulse width).

Bob Ammerman
RAm Systems

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@140934 by Jinx

face picon face
> Er....
>
>     bsf    en
>     nop
>     bcf    en
>
> gives you only 400ns wide en pulse on a 20MHz PIC.
>
> you'll need
>
>     bsf    en
>     nop
>     nop
>     bcf    en
>
> to be safe (at 600ns pulse width).
>
> Bob Ammerman
> RAm Systems

Haha, I thought about that the moment after I shut the PC down last night.
Yes, you do need at least a couple of nops to be safe. The cycle time for
EN (1us) isn't an issue I've come across

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@185806 by David Duffy

flavicon
face
At 10:44 PM 05/12/2002, you wrote:
> >          bsf     lcd_e           ;strobe the lcd e
> >          call    delay_500us     ;line for 500us
> >          bcf     lcd_e           ;
>
>You can strobe EN down to 450ns. For a 20MHz PIC this is
>bsf en  nop  bcf en. Another tip for saving time if you need
>to is how you work the Busy flag. You can check Busy before
>you attempt a write. If the LCD isn't ready, go off and do
>something else, maybe prepare data. Typically the LCD takes
>40us after a data write to be ready for the next. In one app I
>have, the LCD is refreshed during reception of 36400 baud
>serial data. While the RX buffer is filling up there's plenty of
>time to process and write previously receieved data to the LCD

Sorry about that! I grabbed that from old code that I must have
slowed down for debugging at some stage. :-)
David...

___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@205021 by Jinx

face picon face
> Sorry about that! I grabbed that from old code that I must have
> slowed down for debugging at some stage. :-)
> David...

Me too with the one nop. Used 8MHz code as a reference. I
tried an LCD this morning with 400ns EN strobe and it does
work, but obviously not recommended

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@224425 by Bob Barr

flavicon
face
On Thu, 5 Dec 2002 10:39:46 -0500, Bob Ammerman wrote:

>
>Er....
>
>    bsf    en
>    nop
>    bcf    en
>
>gives you only 400ns wide en pulse on a 20MHz PIC.
>
>you'll need
>
>    bsf    en
>    nop
>    nop
>    bcf    en
>
>to be safe (at 600ns pulse width).
>

Just wondering, is there any particular benefit in using two 'NOP's
rather than one 'goto $+1'?

Regards, Bob

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@225509 by David Duffy

flavicon
face
>On Thu, 5 Dec 2002 10:39:46 -0500, Bob Ammerman wrote:
>
> >
> >Er....
> >
> >    bsf    en
> >    nop
> >    bcf    en
> >
> >gives you only 400ns wide en pulse on a 20MHz PIC.
> >
> >you'll need
> >
> >    bsf    en
> >    nop
> >    nop
> >    bcf    en
> >
> >to be safe (at 600ns pulse width).

Bob:

>Just wondering, is there any particular benefit in using two 'NOP's
>rather than one 'goto $+1'?

Code clarity...

___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\05@232009 by Bob Ammerman

picon face
> >you'll need
> >
> >    bsf    en
> >    nop
> >    nop
> >    bcf    en
> >
> >to be safe (at 600ns pulse width).
> >
>
> Just wondering, is there any particular benefit in using two 'NOP's
> rather than one 'goto $+1'?

nope - I just expressed it as two nops to avoid having to explain that goto
is a two cycle instruction, and also what $+1 means.

Bob Ammerman
RAm Systems

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\06@004849 by cdb

flavicon
face
Didn't work though did it :))

I have found some displays are more timing conscious than others.

The code for the sprinkler required a large settling time but only a
NOP at 10MHz. Perhaps the overhead of the C compiler didn't help.

colin
--
cdb, EraseMEbodgy1spam_OUTspamTakeThisOuToptusnet.com.au on 06/12/2002

Light travels faster than sound. That's why some people appear bright
until they speak!

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2002\12\06@004902 by Bob Barr

flavicon
face
On Thu, 5 Dec 2002 23:17:54 -0500, Bob Ammerman wrote:

>>
>> Just wondering, is there any particular benefit in using two 'NOP's
>> rather than one 'goto $+1'?
>
>nope - I just expressed it as two nops to avoid having to explain that goto
>is a two cycle instruction, and also what $+1 means.
>

Thanks, Bob. I thought I might have missed something along the way.


Regards, Bob

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2002\12\06@084920 by Olin Lathrop

face picon face
> Just wondering, is there any particular benefit in using two 'NOP's
> rather than one 'goto $+1'?

Yes.  First and foremost it's a lot clearer what you are trying to do.
Second, the NOPs aren't dependent on PCLATH.

If code space if very tight then saving the extra instruction by using the
GOTO is reasonable, as long as it's well documented.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email KILLspamlistservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body


2002\12\06@085117 by Roman Black

flavicon
face
Bob Barr wrote:

> Just wondering, is there any particular benefit in using two 'NOP's
> rather than one 'goto $+1'?


Yes, the processor uses less power. :o)
-Roman

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2002\12\06@103914 by Bob Barr

flavicon
face
On Fri, 6 Dec 2002 07:44:00 -0500, Olin Lathrop wrote:

>> Just wondering, is there any particular benefit in using two 'NOP's
>> rather than one 'goto $+1'?
>
>Yes.  First and foremost it's a lot clearer what you are trying to do.

True, although I tend to read past a 'goto $+1' as a 2 cycle NOP
anyway.

>Second, the NOPs aren't dependent on PCLATH.

Good point, I hadn't considered that.

>If code space if very tight then saving the extra instruction by using the
>GOTO is reasonable, as long as it's well documented.

Agreed. Sometimes just an instruction or two can make a world of
difference. BTW, when it becomes necessary to crunch a bit of space,
does the MPLAB editor have any way to do a search for two sequential
NOPs to be replaced?


Regards, Bob

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spamBeGonelistservspamBeGonespammitvma.mit.edu with SET PICList DIGEST in the body


2002\12\06@171259 by Jim Main

flavicon
face
Also, a goto $+1 doesn't work on the 18 series - it needs to be goto $+2
(or multiples thereof)


{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservEraseMEspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body


2002\12\06@171712 by Olin Lathrop

face picon face
> Also, a goto $+1 doesn't work on the 18 series - it needs to be goto $+2
> (or multiples thereof)

GOTO $+2 is pointless on the 18 series because a GOTO uses 32 bits, the
same as two NOP instructions.  BRA $+2 does make sense however.  It is
effectively a two cycle NOP using only 16 bits.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body


2002\12\06@190046 by Wouter van Ooijen

face picon face
> GOTO $+2 is pointless on the 18 series because a GOTO uses 32
> bits, the
> same as two NOP instructions.  BRA $+2 does make sense however.  It is
> effectively a two cycle NOP using only 16 bits.

Is the GOTO still a two-cycle instruction on the 18F? I would expect it
to be two fetches and then a flushof the pipeline?

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservEraseMEspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2002\12\07@085005 by Olin Lathrop

face picon face
> Is the GOTO still a two-cycle instruction on the 18F? I would expect it
> to be two fetches and then a flushof the pipeline?

It's two cycles according to the manual.  I imagine the pipeline is
flushed at the same time the second word is fetched.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2002\12\08@123120 by James Newton, webhost

face picon face
source= http://www.piclist.com/postbot.asp?id=piclist\2002\12\05\225509a

For code clarity with reduced lines of code,

nopx2 MACRO
     goto $+1
     ENDM

People don't use macros enough IM(NS)HO. Actually it should be possible to
make a macro called "delay" that accepts parameters of a number and a unit,
(e.g. delay 2, usec) that will generate code for any delay and automatically
compensate for different chips and speeds.

I wrote one for SASM and SX-Key for the SX processors.

---
James Newton: PICList.com webmaster, former Admin #3
RemoveMEjamesnewtonEraseMEspamEraseMEpiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\12\08@124618 by Wouter van Ooijen

face picon face
> Actually it should
> be possible to
> make a macro called "delay" that accepts parameters of a
> number and a unit,
> (e.g. delay 2, usec) that will generate code for any delay
> and automatically
> compensate for different chips and speeds.

Such macro's and a lot more (for instance I/O that is on-off logic
instead of level-base, with the active level defined once) are part of
the Wisp firmware. Free from http://www.voti.nl/wisp. But the macro
language of MPASM is too restricted to do realy usefull things, like
static-stack variable allocation, so I dropped assembly and wrote a
compiler :)

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\12\08@171329 by Steve Smith

flavicon
face
part 1 1263 bytes content-type:text/plain; (decoded 7bit)

Attached various timer functions the delay macro by robin abbot (I
think) was published in EPE ages agoand it works

Regardz Steve

{Original Message removed}
part 2 2671 bytes content-type:application/octet-stream; (decode)

part 3 154 bytes
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\12\09@011744 by Peter McNulty

picon face
What language is that coded in?
----- Original Message -----
From: "Steve Smith" <RemoveMExygaxspam_OUTspamKILLspamBLUEYONDER.CO.UK>
To: <RemoveMEPICLISTTakeThisOuTspamspamMITVMA.MIT.EDU>
Sent: Monday, December 09, 2002 6:12 AM
Subject: Re: [EE]: LCD Initialization and Usage Sequence?


> Attached various timer functions the delay macro by robin abbot (I
> think) was published in EPE ages agoand it works
>
> Regardz Steve
>
> {Original Message removed}

2002\12\10@053956 by o-8859-1?Q?Tony_K=FCbek?=

flavicon
face
Hi,
James Newton wrote:
<snip>
>People don't use macros enough IM(NS)HO. Actually it should be possible
to
>make a macro called "delay" that accepts parameters of a number and a
unit,
>(e.g. delay 2, usec) that will generate code for any delay and
automatically
>compensate for different chips and speeds.
<snip>

Well I think you are partly correct, macros can be quite useful,
but, and this is a big *BUT*, the drawback is added code,
if there is something that is used alot in the code an macro will
expand at each and every location its evoked. The code will
still look small but reading the output will surprise you :)
Anyway I think macros are very good to make the code more readable
for example in placing variables at 'desired' location prior an call,
calcuting constants etc. But it's not good as an replacement for
an general routine.
For instance the delay macro, if used once it's ok, but use it 10 times
then it's just an waste of resources.

An small example where i find macros makes the code more readable:

Assume an function that put an text on an graphic display  at the pixel position x,y. This routine needs atleast three variables
setup prior call:

Pointer- points to text in program mem
VariableX - x pixel position (constant)
VariableY - y pixel position (constant)

These can ofcource be setup 'manually' prior call but macros
make this more redable an less prone to error like this:

       PutFixedTextAtXY  PointerToText,X,Y

Instead of:

       MOVLW   HIGH(PointerToText)
       MOVWF   PutTextLocalHighPtr
       MOVLW   LOW(PointerToText)
       MOVWF   PutTextLocalLowPtr
       MOVLW   X
       MOVWF   PutTextLocalX
       MOVLW   Y
       MOVWF   PutTextLocalY
       CALL    PutText


The key point is that in this case all these steps really are
nessesary prior each call to the routine for the puttext, there
no way around it. Then an macro is not wasteful.


my 2c

/Tony






/Tony

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\10@061935 by Michael Rigby-Jones

picon face
> -----Original Message-----
> From: Tony Kübek [SMTP:EraseMEtony.kubekspamspamspamBeGoneFLINTAB.COM]
> Sent: Tuesday, December 10, 2002 10:39 AM
> To:   RemoveMEPICLISTKILLspamspammitvma.mit.edu
> Subject:      Re: [EE]: LCD Initialization and Usage Sequence?
>
> For instance the delay macro, if used once it's ok, but use it 10 times
> then it's just an waste of resources.
> That depends on the resources I guess.  On a 12 bit core with only 2 stack
levels, the stack is probably one of the scarest resources, and using more
program memory rather than a stack level may well be acceptable.

Mike

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\10@153621 by jamesnewton

face picon face
source= http://www.piclist.com/postbot.asp?id=piclist\2002\12\09\011744a

er... SASM... for the SX's sorry. I forget that MASM has a different
syntax... Hopefully the idea is clear.

---
James Newton: PICList.com webmaster, former Admin #3
jamesnewtonSTOPspamspamspam_OUTpiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\12\11@131247 by Steve Smith

flavicon
face
Written in asm and the macro works

Steve...

-----Original Message-----
From: pic microcontroller discussion list
[spamBeGonePICLISTSTOPspamspamEraseMEMITVMA.MIT.EDU] On Behalf Of Peter McNulty
Sent: 09 December 2002 06:18
To: KILLspamPICLISTspamBeGonespamMITVMA.MIT.EDU
Subject: Re: [EE]: LCD Initialization and Usage Sequence?


What language is that coded in?
----- Original Message -----
From: "Steve Smith" <EraseMExygaxspamEraseMEBLUEYONDER.CO.UK>
To: <@spam@PICLIST@spam@spamspam_OUTMITVMA.MIT.EDU>
Sent: Monday, December 09, 2002 6:12 AM
Subject: Re: [EE]: LCD Initialization and Usage Sequence?


{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email TakeThisOuTlistservKILLspamspamspammitvma.mit.edu with SET PICList DIGEST in the body


2002\12\12@040032 by Peter McNulty

picon face
i thought u couldn't have if statements and equals signs, *'s and /'s in asm
----- Original Message -----
From: "Steve Smith" <.....xygaxspamRemoveMEBLUEYONDER.CO.UK>
To: <RemoveMEPICLISTspamspamBeGoneMITVMA.MIT.EDU>
Sent: Thursday, December 12, 2002 2:11 AM
Subject: Re: [EE]: LCD Initialization and Usage Sequence?


> Written in asm and the macro works
>
> Steve...
>
> {Original Message removed}

2002\12\12@052052 by cdb

flavicon
face
It is a MACRO and you will find that MPASM is quite happy with them.
The IF statements are compiler/assembler directives.

The macro does work it is the main delay routine for the library
files of the C compiler.

Colin
--
cdb, spamBeGonebodgy1@spam@spamspam_OUToptusnet.com.au on 12/12/2002

Light travels faster than sound. That's why some people appear bright
until they speak!

--
http://www.piclist.com hint: To leave the PICList
TakeThisOuTpiclist-unsubscribe-requestspamspammitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...