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.

Trouble w/ LCD on 18F11220

Status
Not open for further replies.

AGCB

Member
I've been fighting for several days with this. The intension is to use a F1220 to display messages and decimal vaues on an LCD. The information comes from a second PIC which is actually doing the experimenting and is sent via USART.

I started w/ Nigel's tutorial 3.3 modified for the 18F. That worked fine except for the 'convert' subroutine but thats OK since I only have 1 byte numbers to display and my 'digbyte' macro works great.

Upon adding subroutines and interrupts to the program, it stoped working, displaying either blank on the LCD or splitting up the Hello message into parts and in different places on the LCD.

Last night I took the program all apart by commenting out all but the PIC header and initialization, then started part by part putting things back in until it failed again. The code snippet below (just the main loop) works fine untill you put any single one of the commented out lines in. Then it goes back to either a blank display or a split up Hello message and no more.

I thought the problem could be a read/write/modify problem because even if you put the 'bcf
portb,1 instruction in it makes it fail. But other delays or even the same delay twice in a row makes it fail too.

Whatever is causing this is probably the same that caused the larger program to fail also.

The calls and delays all work on there own. Only the tone sub has not been tested.

Code:
;================ Main loop=============================
	movlw	.200
	movwf	rcv_temp
	rcall	Hel_dis		;display Hello
	rcall	del_2S		

	bsf	portb,5
	movlw	.40
	movwf	beepcount
	bsf	portb,1
	
;	bcf	latb,1

;	call	del_2s

;	call	ms5

	bcf	portb,1
		
	call	ms5

;	decfsz	beepcount

;	bra	snd

;	call	tone

	call	ad_dis

;	call	tone

	call	del_2s

	call	dspl_dec

;	call	tone
cir	bra	cir

Provided none of the semicolons are removed, the LCD displays 'Hello' then after a second displays 'AD Result' on the top line then the 'rcv_temp' decimal on the bottom line.

Your good advice will be appreciated!
 
Still fighting with this.

It makes no sense that any of the instructions listed would cause failure.

What effect would removing the pull up resistor on RA4 have? It seems that I accidentally removed it at some point. It is the RS line to the LCD.

Would this cause irratic operation that seems like ESD input? I mean hovering my hand over the PIC changes output.
 
Last edited:
What effect would removing the pull up resistor on RA4 have? It seems that I accidentally removed it at some point. It is the RS line to the LCD.

Would this cause irratic operation that seems like ESD input? I mean hovering my hand over the PIC changes output.

Definitely...... May I ask why you use LATB...and PORTB... Its recommended that LATB be used on outputs
 
Ian
Only because I was trying to figure out what was going on and what kind of instructions caused the problem. I'm not sure I know the difference between LATB and PORTB or why use one and not the other.

Yesterday as i was trying different things it was really weird because it was as if I had power in my hand to turn on and off the power to the LCD which is controlled by the pic through a opto isolator. Also, turning on or off my CRT monitor would affect the output. This morning as I was rebuilding the circuit around a 628A, I noticed the pull up resistor on RA4 was not there.

So I'm assuming that without that resistor on RA4, the output sort of floats around? Is that right?
 
LATB latches the port and PORT doesn't on the 18F chips LATB makes sure there is not a read write modify problems

Like the 16f and 12F chips

The data latch (LAT register) is useful for read-modifywrite
operations on the value that the I/O pins are
driving
 
Last edited:
So I'm assuming that without that resistor on RA4, the output sort of floats around? Is that right?

All I know is that ISIS won't simulate properly unless RA4 has an external pullup ( When I did the tutorials on the pic16f628a, I had to use one).
 
Well! I finally got it. I'm back where I was 7 days ago and now progressing. The thing that started the whole episode was the removal of that RA4 pull up resistor. I don't know when I removed it or why, but from that point in my quest to figure it out the program was changed many times all to no avail and all got messed up so it took two days to straighten it out.

A few points I learned in the last week are

1. the importance of the pull up on RA4

2. When working on a large program, copy and save the program in a separate file at regular milestones so if something gets messed up you don't have to start over at square one

3. heating months bring on lots of static. Ground yourself, the table, the ground bus .

4. write simple loops and use subs for everything you can

5. if it seems like the program should work, CHECK THE CIRCUIT and CHECK AGAIN!!!

Thanks to all who responded. Again, I learned more on this forum than I expected. Aaron
 
Number 5 is away's the show stopper. One never wants to think it could be wired wrong. Kind of like see no evil do no evil only true when we are a sleep. LOL
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top