Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD display problem in the code

Status
Not open for further replies.

smileguitar

Newbie level 4
Joined
Dec 18, 2007
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,341
Code:
	LIST P=16F877
	#INCLUDE <P16F877.INC>
	errorlevel -302
	errorlevel -207
	__CONFIG _CP_OFF & _PWRTE_ON & _XT_OSC & _WDT_OFF

;==========VARIABLE===============

			CBLOCK	0X20
			NUM1		;FOR NUMBER
			NUM2		;FOR NUMBER
			NUM3		;FOR NUMBER
			NUM4		;FOR NUMBER
			D1
			D2
			D3
			D4
			ENDC

			ORG	0X00
			GOTO	START

TEXT		CALL	LCD_INIT
		BSF	PORTB,2		;R/S SET TO '1'
		MOVLW	H'45'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'6E'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'74'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'65'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'72'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'20'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'43'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'6F'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'64'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'65'
		MOVWF	PORTD
		CALL	CLOCK_E
		RETLW	0X00

WRONG		CALL	LCD_INIT
		CALL	LCD_LINE2
		BSF	PORTB,2		;R/S SET TO '1'
		MOVLW	H'57'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'72'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'6F'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'6E'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'67'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'20'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'43'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'6F'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'64'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'65'
		MOVWF	PORTD
		CALL	CLOCK_E
		RETLW	0X00

CORRECT		CALL	LCD_INIT
		CALL	LCD_LINE2
		BSF	PORTB,2		;R/S SET TO '1'
		MOVLW	H'43'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'6F'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'72'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'72'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'65'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'63'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'74'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'20'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'43'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'6F'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'64'
		MOVWF	PORTD
		CALL	CLOCK_E
		MOVLW	H'65'
		MOVWF	PORTD
		CALL	CLOCK_E
		RETLW	0X00

START		BSF	STATUS,RP0
		MOVLW	B'00000001'
		MOVWF	TRISB
		MOVLW	B'00000000'
		MOVWF	TRISD
		BCF	STATUS,RP0
		CLRF	PORTB
		CLRF	PORTD
		GOTO	BEGIN

BEGIN		CALL	TEXT
		BTFSC	PORTB,0		;SKIP IF ENTER=1
		GOTO	BEGIN		;IF ENTER=0 GO TO START

ONE		MOVLW	D'1'
		MOVWF	NUM1		;SET NUM1=1
		SUBLW	B'00000001'	;NUM1-1
		BTFSS	STATUS,Z	;NUM1-1=0?
		GOTO	TWO		;YES, GO TO NEXT NUMBER
		GOTO	WRONG

TWO		MOVLW	D'2'		
		MOVWF	NUM2		;SET NUM1=2
		SUBLW	B'00000010'	;NUM2-2
		BTFSS	STATUS,Z	;NUM2-2=0?
		GOTO	THREE		;YES, GO TO NEXT NUMBER
		GOTO	WRONG

THREE		MOVLW	D'3'		
		MOVWF	NUM3		;SET NUM1=3
		SUBLW	B'00000011'	;NUM3-3	
		BTFSS	STATUS,Z	;NUM3-3=0?
		GOTO	FOUR		;YES, GO TO NEXT NUMBER
		GOTO	WRONG

FOUR		MOVLW	D'4'		
		MOVWF	NUM4		;SET NUM1=4
		SUBLW	B'00000100'	;NUM4-4
		BTFSS	STATUS,Z	;NUM4-4=0?
		GOTO	WRONG		;NO, RETURN TO START
		GOTO	CORRECT
		BSF	PORTB,5

LCD_INIT	BCF	PORTB,2
		MOVLW	B'00110000'
		MOVWF	PORTD		;FUNCTION SET: 8 BIT INTERFACE
		CALL	CLOCK_E
		MOVLW	B'00001100'
		MOVWF	PORTD		;DISPALY & CURSOR: SET TO DISPLAY ON; CURSOR UNDERLINE OFF; CURSOR BLINK OFF
		CALL	CLOCK_E
		MOVLW	B'00111000'
		MOVWF	PORTD		;FUNCTION SET: 8 BIT; 2 LINE MODE; 5X10 DOT FORMAT
		CALL	CLOCK_E
		MOVWF	B'00000001'
		MOVWF	PORTD		;CLEAR DISPLAY
		CALL	CLOCK_E
		MOVLW	B'00000110'
		MOVWF	PORTD		;CHARACTER ENTRY MODE: INCREMENT; DISPLAY SHIFT ON
		CALL	CLOCK_E
		RETLW	0X00

LCD_LINE2	BCF	PORTB,2		; R/S SET TO '0'
		MOVLW	B'11000000'
		MOVWF	PORTD		; JUMP TO 2ND LINE
		CALL	CLOCK_E
		RETLW	0X00

CLOCK_E		BSF	PORTB,1
		CALL	DELAY2
		BCF	PORTB,1
		RETLW	0X00

DELAY1		MOVLW	D'130'
		MOVWF	D2
		MOVLW	D'221'
		MOVWF	D1
LOOP1		DECFSZ	D1,1
		GOTO	LOOP1
		DECFSZ	D2,1
		GOTO	LOOP1
		RETLW	0X00

DELAY2		MOVLW	D'13'		;DELAY 10ms
		MOVWF	D4
		MOVLW	D'251'
		MOVWF	D3
LOOP2		DECFSZ	D3,1
		GOTO	LOOP2
		DECFSZ	D4,1
		GOTO	LOOP2
		RETLW	0X00

		END

Hello everyone. I'm doing a project that using infrared to open the door.Transmitter is keypad for keying passwords and send to receiver (what I'm doing) to display the passwards in '*' and compare the passwards are correct or incorrect with telling the user by LCD. Above is the coding I created. For my concept is when the keypad is being press (like enter), I'll get the signal and compare the original passwards. Before that, "Enter Code" is promted.

I have download this coding into PIC 16F877 (PIC I'm using), and test it. I found a problem before I press a button, which the promted "Enter Code" is displaying unstopable like "Enter Code Enter Code Enter Code.....". Besides that, when I press the button, LCD display "Enter Code Enter Code Enter Code..Wrong Code Enter Code...." What is the problem? How could I stop it? Is my coding correct?

Someone can give me a hand solving my problem? I'm appreciating it. Thanks in advanced.

Added after 5 hours 9 minutes:

Anyone who is experienced can give suggestion? I've a lot of questions not understand yet, need help....
 

Re: LCD Display Problem

i have not used PIC.

so i can't help in code..

but if you have any logical questions then i can try...
if you wish then feel free to post questions..

thank you
 

LCD Display Problem

Use the simulator coming with MPLAB from Microchip.

Once you cycle through your software, you could se why / where it is wrong.
 

Re: LCD Display Problem

H_D_R said:
i have not used PIC.

so i can help in code..

but if you have any logical questions then i can try...
if you wish then feel free to post questions..

thank you


ok, thanks for your kindness. I'll post a lot of questions about PIC coding (assembly language) since I've a lot of coding not understanding yet.

Thanks in advance!

Added after 4 minutes:

atferrari said:
Use the simulator coming with MPLAB from Microchip.

Once you cycle through your software, you could se why / where it is wrong.

What did you mean by simulator coming with MPLAB from microchip? It is a software simulator?
 

Re: LCD Display Problem

smileguitar said:
H_D_R said:
i have not used PIC.

so i can help in code..

but if you have any logical questions then i can try...
if you wish then feel free to post questions..

thank you


ok, thanks for your kindness. I'll post a lot of questions about PIC coding (assembly language) since I've a lot of coding not understanding yet.

Thanks in advance!

sorry, by mistake i had written that sentence.
actually, i have not used PIC yet so how can i help you in code..??
i have updated that post also.
ya, i will try to help you to solve your logical questions.

sorry for my mistake..
 

Re: LCD Display Problem

Hi Smileguitar,

Problem #1:
You are looping the Begin routine with text.

Change code from
Code:
BEGIN      CALL   TEXT 
      BTFSC   PORTB,0      ;SKIP IF ENTER=1 
      GOTO   BEGIN      ;IF ENTER=0 GO TO START

to

Code:
      CALL   TEXT 
BEGIN      BTFSC   PORTB,0      ;SKIP IF ENTER=1 
      GOTO   BEGIN      ;IF ENTER=0 GO TO START


Problem #2:
Defined correct and wrong codes as function. But in the code U implemented as goto statement.

Try changing the code from
Code:
FOUR      MOVLW   D'4'       
      MOVWF   NUM4      ;SET NUM1=4 
      SUBLW   B'00000100'   ;NUM4-4 
      BTFSS   STATUS,Z   ;NUM4-4=0? 
      GOTO   WRONG      ;NO, RETURN TO START 
      GOTO   CORRECT 
      BSF   PORTB,5

to

Code:
FOUR      MOVLW   D'4'       
      MOVWF   NUM4      ;SET NUM1=4 
      SUBLW   B'00000100'   ;NUM4-4 
      BTFSS   STATUS,Z   ;NUM4-4=0? 
      GOTO   WRONGCHK      ;NO, RETURN TO START 
      GOTO   CORRECTCHK

WRONGCHK      CALL   WRONG
      CALL  TEXT
      GOTO   BEGIN

CORRECTCHK      CALL  CORRECT
      BSF   PORTB,5     ;I GUESS THIS IS FOR ACTIVATING LED / RELAY IF THE CODE IS CORRECT. 
                                   ;OTHERWISE USE AT APPROPRIATE PLACE


Hope this helps...

- Nishal

Added after 6 minutes:

Hi smileguitar

Also correct these lines too.

Change code from
Code:
ONE      MOVLW   D'1' 
      MOVWF   NUM1      ;SET NUM1=1 
      SUBLW   B'00000001'   ;NUM1-1 
      BTFSS   STATUS,Z   ;NUM1-1=0? 
      GOTO   TWO      ;YES, GO TO NEXT NUMBER 
      GOTO   WRONG 

TWO      MOVLW   D'2'       
      MOVWF   NUM2      ;SET NUM1=2 
      SUBLW   B'00000010'   ;NUM2-2 
      BTFSS   STATUS,Z   ;NUM2-2=0? 
      GOTO   THREE      ;YES, GO TO NEXT NUMBER 
      GOTO   WRONG 

THREE      MOVLW   D'3'       
      MOVWF   NUM3      ;SET NUM1=3 
      SUBLW   B'00000011'   ;NUM3-3    
      BTFSS   STATUS,Z   ;NUM3-3=0? 
      GOTO   FOUR      ;YES, GO TO NEXT NUMBER 
      GOTO   WRONG 

FOUR      MOVLW   D'4'       
      MOVWF   NUM4      ;SET NUM1=4 
      SUBLW   B'00000100'   ;NUM4-4 
      BTFSS   STATUS,Z   ;NUM4-4=0? 
      GOTO   WRONG      ;NO, RETURN TO START 
      GOTO   CORRECT 
      BSF   PORTB,5

to

Code:
ONE      MOVLW   D'1' 
      MOVWF   NUM1      ;SET NUM1=1 
      SUBLW   B'00000001'   ;NUM1-1 
      BTFSS   STATUS,Z   ;NUM1-1=0? 
      GOTO   TWO      ;YES, GO TO NEXT NUMBER 
      GOTO    WRONGCHK

TWO      MOVLW   D'2'       
      MOVWF   NUM2      ;SET NUM1=2 
      SUBLW   B'00000010'   ;NUM2-2 
      BTFSS   STATUS,Z   ;NUM2-2=0? 
      GOTO   THREE      ;YES, GO TO NEXT NUMBER 
      GOTO    WRONGCHK

THREE      MOVLW   D'3'       
      MOVWF   NUM3      ;SET NUM1=3 
      SUBLW   B'00000011'   ;NUM3-3    
      BTFSS   STATUS,Z   ;NUM3-3=0? 
      GOTO   FOUR      ;YES, GO TO NEXT NUMBER 
      GOTO    WRONGCHK

FOUR      MOVLW   D'4'        
      MOVWF   NUM4      ;SET NUM1=4 
      SUBLW   B'00000100'   ;NUM4-4 
      BTFSS   STATUS,Z   ;NUM4-4=0? 
      GOTO   WRONGCHK      ;NO, RETURN TO START 
      GOTO   CORRECTCHK 

WRONGCHK      CALL   WRONG 
      CALL  TEXT 
      GOTO   BEGIN 

CORRECTCHK      CALL  CORRECT 
      BSF   PORTB,5     ;I GUESS THIS IS FOR ACTIVATING LED / RELAY IF THE CODE IS CORRECT. 
                                   ;OTHERWISE USE AT APPROPRIATE PLACE



CHEERS

- NISHAL
 

Re: LCD Display Problem

H_D_R said:
smileguitar said:
H_D_R said:
i have not used PIC.

so i can help in code..

but if you have any logical questions then i can try...
if you wish then feel free to post questions..

thank you


ok, thanks for your kindness. I'll post a lot of questions about PIC coding (assembly language) since I've a lot of coding not understanding yet.

Thanks in advance!

sorry, by mistake i had written that sentence.
actually, i have not used PIC yet so how can i help you in code..??
i have updated that post also.
ya, i will try to help you to solve your logical questions.

sorry for my mistake..

Is ok. Thanks!

Added after 6 minutes:

nishal said:
Hi Smileguitar,

Problem #1:
You are looping the Begin routine with text.

Change code from
Code:
BEGIN      CALL   TEXT 
      BTFSC   PORTB,0      ;SKIP IF ENTER=1 
      GOTO   BEGIN      ;IF ENTER=0 GO TO START

to

Code:
      CALL   TEXT 
BEGIN      BTFSC   PORTB,0      ;SKIP IF ENTER=1 
      GOTO   BEGIN      ;IF ENTER=0 GO TO START


Problem #2:
Defined correct and wrong codes as function. But in the code U implemented as goto statement.

Try changing the code from
Code:
FOUR      MOVLW   D'4'       
      MOVWF   NUM4      ;SET NUM1=4 
      SUBLW   B'00000100'   ;NUM4-4 
      BTFSS   STATUS,Z   ;NUM4-4=0? 
      GOTO   WRONG      ;NO, RETURN TO START 
      GOTO   CORRECT 
      BSF   PORTB,5

to

Code:
FOUR      MOVLW   D'4'       
      MOVWF   NUM4      ;SET NUM1=4 
      SUBLW   B'00000100'   ;NUM4-4 
      BTFSS   STATUS,Z   ;NUM4-4=0? 
      GOTO   WRONGCHK      ;NO, RETURN TO START 
      GOTO   CORRECTCHK

WRONGCHK      CALL   WRONG
      CALL  TEXT
      GOTO   BEGIN

CORRECTCHK      CALL  CORRECT
      BSF   PORTB,5     ;I GUESS THIS IS FOR ACTIVATING LED / RELAY IF THE CODE IS CORRECT. 
                                   ;OTHERWISE USE AT APPROPRIATE PLACE


Hope this helps...

- Nishal

Added after 6 minutes:

Hi smileguitar

Also correct these lines too.

Change code from
Code:
ONE      MOVLW   D'1' 
      MOVWF   NUM1      ;SET NUM1=1 
      SUBLW   B'00000001'   ;NUM1-1 
      BTFSS   STATUS,Z   ;NUM1-1=0? 
      GOTO   TWO      ;YES, GO TO NEXT NUMBER 
      GOTO   WRONG 

TWO      MOVLW   D'2'       
      MOVWF   NUM2      ;SET NUM1=2 
      SUBLW   B'00000010'   ;NUM2-2 
      BTFSS   STATUS,Z   ;NUM2-2=0? 
      GOTO   THREE      ;YES, GO TO NEXT NUMBER 
      GOTO   WRONG 

THREE      MOVLW   D'3'       
      MOVWF   NUM3      ;SET NUM1=3 
      SUBLW   B'00000011'   ;NUM3-3    
      BTFSS   STATUS,Z   ;NUM3-3=0? 
      GOTO   FOUR      ;YES, GO TO NEXT NUMBER 
      GOTO   WRONG 

FOUR      MOVLW   D'4'       
      MOVWF   NUM4      ;SET NUM1=4 
      SUBLW   B'00000100'   ;NUM4-4 
      BTFSS   STATUS,Z   ;NUM4-4=0? 
      GOTO   WRONG      ;NO, RETURN TO START 
      GOTO   CORRECT 
      BSF   PORTB,5

to

Code:
ONE      MOVLW   D'1' 
      MOVWF   NUM1      ;SET NUM1=1 
      SUBLW   B'00000001'   ;NUM1-1 
      BTFSS   STATUS,Z   ;NUM1-1=0? 
      GOTO   TWO      ;YES, GO TO NEXT NUMBER 
      GOTO    WRONGCHK

TWO      MOVLW   D'2'       
      MOVWF   NUM2      ;SET NUM1=2 
      SUBLW   B'00000010'   ;NUM2-2 
      BTFSS   STATUS,Z   ;NUM2-2=0? 
      GOTO   THREE      ;YES, GO TO NEXT NUMBER 
      GOTO    WRONGCHK

THREE      MOVLW   D'3'       
      MOVWF   NUM3      ;SET NUM1=3 
      SUBLW   B'00000011'   ;NUM3-3    
      BTFSS   STATUS,Z   ;NUM3-3=0? 
      GOTO   FOUR      ;YES, GO TO NEXT NUMBER 
      GOTO    WRONGCHK

FOUR      MOVLW   D'4'        
      MOVWF   NUM4      ;SET NUM1=4 
      SUBLW   B'00000100'   ;NUM4-4 
      BTFSS   STATUS,Z   ;NUM4-4=0? 
      GOTO   WRONGCHK      ;NO, RETURN TO START 
      GOTO   CORRECTCHK 

WRONGCHK      CALL   WRONG 
      CALL  TEXT 
      GOTO   BEGIN 

CORRECTCHK      CALL  CORRECT 
      BSF   PORTB,5     ;I GUESS THIS IS FOR ACTIVATING LED / RELAY IF THE CODE IS CORRECT. 
                                   ;OTHERWISE USE AT APPROPRIATE PLACE



CHEERS

- NISHAL

Wow! Thanks for your help. But why need WRONGCHK and CORRECTCHK? What is the instruction is for?
 

LCD Display Problem

Hi smileguitar,
Nice to hear from U that it is working.
Explanation : wrongchk & correctchk
consider the direct function calling as u did
-------------------------------------------------
BTFSS STATUS,Z ;NUM4-4=0?
CALL WRONG ;NO, RETURN TO START
CALL CORRECT
---------------------------------------------
(I have corrected your statement goto to call statement in the above example.) The code will check for the 4th num if that is false it will execute the wrong function first and it will execute correct function also.

To avoid this situation, wrongchk and correctchk is required

cheers

Nishal
 

Re: LCD Display Problem

hi

The problem is that after you prompt "enter code", the pic returs quickly to scan what happen on its ports. And well, press the enter buttom, to human, takes a little time, let's say a few miliseconds.
So, when pic returns to scan their ports, enter buttom still pressed (check debounce too) and think as a new wrong code entered.

To solve the problem, give to program delays or design a tiny RC filter to connect to enter buttom.

This way your problem shall dissapear.

good luck
 

LCD Display Problem

I see, Thanks! Now I understand.

I've another question, due to my coding, how could I clear the LCD after displaying? I've been try to use B'00000001' to clear it, but not.
 

Re: LCD Display Problem

smileguitar said:
I see, Thanks! Now I understand.

I've another question, due to my coding, how could I clear the LCD after displaying? I've been try to use B'00000001' to clear it, but not.


Code:
SETFT	MACRO	  nFSR,TC
	               MOVLW	nFSR
	               MOVWF	FSR
	               MOVLW	TC
	               MOVWF	tempct
	               ENDM

Sounds like you are at the point you need to be using macros. Look at the above, one from some of my old code. It would let me set the FSR to the right calculated values for a loop from their storage locations simply by typing "SETFT". By typing SETFT, my code was more readable and I didn't leave something out.

Your clear not working sounds like you've probably left out setting register/command or some other bit. If you use a macro and you have your macro right it will always explicitly set register/command and everything else every time you type CLEARLCD or similar.

When you've used a series of macros and it's more readable and you know the macros explicitly set the bits every time, it's far more likely to work correctly on the first pass. Now often I don't do this either and just code direct, but if it doesn't work right first pass or you can't quickly find the problem with a second look, you should immediately switch to separating it out in this manner. Something like:

CLEARLCD
SENDCMDxx1
SENDCMDxx2
SENDCHR1
CLOCKE
SENDCHR2
CLOCKE


Etc etc. If you organize it in this manner it is easy to keep your operations logically correct, and you have control over each macro to make sure each one is setting every related bit each time. AFTER it's working, then you can use cut/paste to expand each macro, then go back through and cut out the redundant operations, where you've set say the register/command bit to the same value several times in order in several routines. If you cut one too many and it stops working, you know that set or clear wasn't as redundant as it looked.

If you don't do this, then it's very easy to be thinking you're still in command mode or similar when really some other routine came back after setting you to data mode. If your code doesn't set it explicitly every time it's just too easy be thinking you're in one mode or another when you're not, and just keep reading past it because your code still looks correct. The simulator and breakpoints can help you find these, but really it's faster and more reliable to code as above, you'll be less likely to have missed something even if the bug doesn't show up in initial tests.

I have extremely good logic compared to most people, and can write pages and pages of code often without any errors at all, and almost always with no more than a careless error or two, where I was thinking correctly but not paying attention and typed the opposite instruction without thinking about it. But errors of first type can be much more subtle, no matter how much you look it just may not come into mind that you've forgotten to set a bit back to the right value or that it's gotten set wrong somewhere else. You have to make code that's gone through and very clearly been set up to set everything every time, then take out the redundancies, if you don't then you can waste an awful lot of time chasing a relatively minor problem.



Code:
TEXT         CALL   LCD_INIT
             BSF   PORTB,2      ;R/S SET TO '1'
             MOVLW   H'45'
             MOVWF   PORTD
             CALL   CLOCK_E
             MOVLW   H'6E'
             MOVWF   PORTD
             CALL   CLOCK_E



SENDLCD   MACRO  CHAR
             MOVLW  CHAR
             MOVWF  PORTD
             CALL     CLOCKE
             ENDM

TEXT2
              CALL  LCDINIT
              SETRS
              SENDLCD H'45'
              SENDLCD H'6E'
              ...

SETRS would be another simple macro, LCDINIT probably should stay a routine since you're likely to call it elsewhere.

Note just how much clearer the second method becomes to see what's going on, not to mention you've done a whole lot less typing or cut and paste because that macro saved many keystrokes. And if something doesn't work first pass, you tweak your macros to set every last little detail related to doing their operation, and you know it got set properly every time you did that macro. Just look at how much that one SENDLCD routine would simplify your code, and make it easier to look through and trouble shoot. For strings like this it's easier to make data strings and a routine to print them, but even if you just want to do it quick and dirty and inline, you need to be using macros so it's easier to work with.

And you are aware you can send:

SENDLCD 'A'
SENDLCD 'l'
SENDLCD 'a'
SENDLCD 'n'

Instead of doing hex codes for everything? You're at the point where you really need to start learning the assembler features as much as how to run LCD x or other item y, because you can learn all of those things several times faster after you're using macros etc to deal with them more easily.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top