Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Problem with CALL in a simple LCD program...

Status
Not open for further replies.

si2030

Member
Hi all,

This one could also be fundamental...

I am building a LCD program and learning at the same time. I have included the program as it stands at the moment.

I am stepping through it but its doing some weird stuff first in the delay routines and also when it calls the CMND2LCD routine... basically I use a call statement to this routine and it wont go there.. just skips over it.. and I dont know why.

Also, when I start the stepping the first thing it is suppose to do is go to START. It actually goes to the space just before the RETURN just above the START routine... again I would have thought it would go directly to START...

Wondering if you could help me with these two issues....


Kind Regards

Simon
 

Attachments

  • LCD 1-0..asm
    12.8 KB · Views: 141
What do you think your code is going to do after it returns from the call to INITLCD?

Code:
;===========================================================================
START
		CALL INITPIC
		CALL INITLCD
[COLOR="red"]Loop		goto	Loop[/COLOR]
;===========================================================================
You need to add the line in red.

Also you have lots of labels that are not in column one. I.E.
Code:
;===========================================================================
;DECLARATIONS.
;===========================================================================

			RESET_V	EQU	0X0000	; ADDRESS OF RESET VECTOR.
			ISR_V	EQU	0X0004	; ADDRESS OF INTERRUPT VECTOR.
			OSC_FREQ EQU D'4000000'	; OSCILLATOR FREQUENCY IS 4 MHZ.
			
			LCD_E		EQU		3
			LCD_RW		EQU		2
			LCD_RS		EQU		1

Should be,
Code:
;===========================================================================  
;DECLARATIONS.
;===========================================================================  

RESET_V		equ	0X0000		; ADDRESS OF RESET VECTOR.
ISR_V		equ	0X0004		; ADDRESS OF INTERRUPT VECTOR.
OSC_FREQ	equ	D'4000000'	; OSCILLATOR FREQUENCY IS 4 MHZ.

LCD_E		equ	3
LCD_RW		equ	2
LCD_RS		equ	1

Mike.
 
Hi Mike, Others

Its getting late and I put this reply to one of my other threads... sorry for that.

I have added that line and I moved the START routine but it keeps jumping over the call statements.

I have added a jing video to show what it does... it shifts the literal values into w and jumps... also the debugger seems to stop on white space between the lines..

**broken link removed**

I have also added the asm file so you can see the program..

Not sure why its jumping over the call statements..

Kind Regards

Simon
 

Attachments

  • LCD 1-0..asm
    11.5 KB · Views: 103
Hi,

If you Sim your code as shown in the jpeg, and open up the View - DisAssembly List you can see that first, your delays are wrong, and second that those calls you say it is jumping over are being interpreted as something else and being ignored.


Have not seen that before and cannot say what is happening there - however my own lcd code runs fine.
( I'm sure Pommie with his much greater experience can explain that one ..? )

The lcd routine is one of the hardest for a beginner to get to grips with - so trying to write you own from scratch is even a more daunting task.

Apart from the difficult software, many diyers come to grief with the actual building of the pic to lcd circuit, so would really suggest you first prove your hardware with a tutorial example like this

Once its all working, go back and try your own code again, this time using Nigels code as a guide.
 

Attachments

  • LCD..jpg
    LCD..jpg
    147.3 KB · Views: 118
The worrying bit here is that your simulator is stepping into blank lines. Have you re-assembled your code after you have edited it? Have you changed your processor from the one you started with (so you think you are evaluating with one processor, but your simulator is simulating a different processor)? Indeed is the code you are editing the one that you are simulating? All of the above problems I have blundered into and got similar results
 
I just tried you code in MPLAB and it simulates correctly. Are you assembling it (F10) before you run it?

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top