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 PIC16F877+LCD display

Status
Not open for further replies.

meera83

New Member
i m asking to use PIC16F877 to do a text display on LCD..
the LCD that i use is on the PICDEM 2PLUS...

i had wrote the code to display the text, but it seen like show nothing..
i don't know where my mistake is....
 

Attachments

  • pic877.txt
    4.3 KB · Views: 428
You appear to have initialisation code for 8 bit mode and write data for 4 bit mode. Have you combined code from 2 different sources?

As a starting point, look at Nigel's LCD tutorial. He should be around soon and the link is in his sig + in the sticky.

Mike.
 
combined code from 2 different sources??

i don't understand with what you mean..is it my source code have mistake? may i know which part of code should i correct it??
i only program this file inside PIC, no any other file...

yap, before that, i had go through Nigel's LCD tutorial 3..
since i had to use PICDEM 2 PLUS to program it and display on its LCD, i had to change the code inside the tutorial(for the port pin)..

since i new to LCD step source code, i fail to make the LCD work...the LCD display seen like didn't have any respond...

thanks..May You Be Well And Happy...
 
You appear to have bit 7 of the LCD connected to Port D bit 3.
You then write a full byte in INIT_LCD.
Code:
INIT_LCD
	BCF		PORTA,3
	MOVLW	b'00101000'			;10h + 08h
	MOVWF	PORTD
You then write 4 bit data in
Code:
LCD_Char	movwf		templcd
		swapf		templcd,w		;send upper nibble
		andlw		0x0f			;clear upper 4 bits of W
		movwf		PORTD
		bsf		PORTA,3			;RS line to 1
		call		Pulse_e			;Pulse the E line high

		movf		templcd,w		;send lower nibble
		andlw		0x0f			;clear upper 4 bits of W
		movwf		PORTD
This last bit of code looks like Nigel's.

This is why I can't follow your code. It switches from 8 bit to 4 bit. It cannot be both.

I would suggest modifying Nigel's code and get that working first.

Mike
 
i just edit the source code from example using 8-bit data bus LCD...

since the LCD that i used on PICDEM 2 PLUS which the connection is for 4-bit data bus LCD, so i copy the 4-bit source code from Nigel's example..

i didn't understand with the step of code should go through, so i unable to write a right code..

ok, i will try to understand with the Nigel's tutorial 3 and do some editing from the code..

that Nigel's code is it just need to load with one file?don't need load other file?

thanks...
 
House0Fwax said:
Code:
	movlw		b'110001'
	movwf		TRISA

I may well be wrong here, but that doesn't look right to me.

I would be much happier with 8 bits in the binary value - I'm always concerned that I'm not 100% sure which way the assembler might justify the 6 to 8!.
 
Nigel Goodwin said:
I would be much happier with 8 bits in the binary value - I'm always concerned that I'm not 100% sure which way the assembler might justify the 6 to 8!.

It would of course take B'1' as 128.

Mike
 
Nigel Goodwin said:
I would be much happier with 8 bits in the binary value - I'm always concerned that I'm not 100% sure which way the assembler might justify the 6 to 8!.

movlw b'110001'
movwf TRISA

the PIC16F877 got only 6 bits RA0-RA5, so i just b'110001' not b'8 bit'...

thanks.. :)
 
meera83 said:
movlw b'110001'
movwf TRISA

the PIC16F877 got only 6 bits RA0-RA5, so i just b'110001' not b'8 bit'...

thanks.. :)

But W has 8 bits, so are you loading it's top 6 bits?, or it's bottom 6 bits? - like I said, I'd be MUCH happier to see 8 bits so you KNOW it's correct.

You can't load W with only 6 bits, so make sure it's loading the bits in the place you want.
 
Obviously he would be on the safe side using 8 bits (I do that every time), but actually he's loading the six less significant bits of the TRISA register.
 
Last edited:
eng1 said:
Obviously he would be on the safe side using 8 bits (I do that every time), but actually he's loading the six less significant bits of the TRISA register.

Probably so - but I would have to look it up (probably every time I used), and then I'd disassemble the HEX file to make absolutely sure! :D

Far easier to do it with 8 bits in the first place!.
 
I assumed everyone was talking tongue in cheek and joking around.
If you see movlw 0x9 (only 4 bits) do you assume it will add a trailing zero and load 0x90 into W.
When I posted above, "It would of course take B'1' as 128." I was joking.
I don't think I have ever come across a situation where you add trailing zeroes.

Mike.
 
Pommie said:
I assumed everyone was talking tongue in cheek and joking around.
If you see movlw 0x9 (only 4 bits) do you assume it will add a trailing zero and load 0x90 into W.
When I posted above, "It would of course take B'1' as 128." I was joking.
I don't think I have ever come across a situation where you add trailing zeroes.

I'm VERY distrustful :D
 
Help!Help! i really don't know what can i do with the source code..

I had make some changing to Nigel's LCD tutorial according to my port pin,
from PICDEM 2 PLUS circuit shcematic, the port pin
RA1 - E
RA2 - RW
RA3 - RS

DB4 - RD0
DB5 - RD1
DB6 - RD2
DB7 - RD3

but the LCD still don't have any respond..
 
meera83 said:
Help!Help! i really don't know what can i do with the source code..

I had make some changing to Nigel's LCD tutorial according to my port pin,
from PICDEM 2 PLUS circuit shcematic, the port pin
RA1 - E
RA2 - RW
RA3 - RS

DB4 - RD0
DB5 - RD1
DB6 - RD2
DB7 - RD3

but the LCD still don't have any respond..



this is the changing code that i program in PIC..
 

Attachments

  • lcd1.txt
    5.8 KB · Views: 189
what's mean by this code?

LCD_RS Equ 0x04 ;LCD handshake lines
LCD_RW Equ 0x06
LCD_E Equ 0x07

if my port pin connection is like
RA1 - E
RA2 - RW
RA3 - RS

DB4 - RD0
DB5 - RD1
DB6 - RD2
DB7 - RD3

then what location should i write??

thanks..
 
meera83 said:
this is the changing code that i program in PIC..
Your attachment is only this:
Code:
	list      p=16f877            ; list directive to define processor
	#include <p16f877.inc>        ; processor specific variable definitions
	
	__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _LP_OSC & _WRT_ENABLE_OFF & _LVP_OFF & _DEBUG_OFF & _CPD_OFF 

; '__CONFIG' directive is used to embed configuration data within .asm file.
; The labels following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configur
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top