Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 8th June 2007, 08:51 AM   #1
Default problem with PIC16F877+LCD display

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....
Attached Files
File Type: txt pic877.txt (4.3 KB, 94 views)
meera83 is offline  
Old 8th June 2007, 09:39 AM   #2
Default

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.
Pommie is online now  
Old 8th June 2007, 10:28 AM   #3
Default

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...
meera83 is offline  
Old 8th June 2007, 10:47 AM   #4
Default

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
Pommie is online now  
Old 8th June 2007, 10:59 AM   #5
Default

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...
meera83 is offline  
Old 8th June 2007, 11:44 AM   #6
Default

Quote:
Originally Posted by meera83
that Nigel's code is it just need to load with one file?don't need load other file?
Each of my tutorials is fully working as it is, just the one file.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 8th June 2007, 12:07 PM   #7
Default

Code:
	movlw		b'110001'
	movwf		TRISA
I may well be wrong here, but that doesn't look right to me.
House0Fwax is offline  
Old 8th June 2007, 01:33 PM   #8
Default

Quote:
Originally Posted by House0Fwax
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!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 8th June 2007, 03:29 PM   #9
Default

Quote:
Originally Posted by Nigel Goodwin
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
Pommie is online now  
Old 8th June 2007, 03:39 PM   #10
Default

P.S. I quoted the wrong post. The irony is fully appreciated.
Pommie is online now  
Old 8th June 2007, 04:20 PM   #11
Default

Quote:
Originally Posted by Nigel Goodwin
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 is offline  
Old 8th June 2007, 04:34 PM   #12
Default

Quote:
Originally Posted by meera83
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.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 8th June 2007, 06:24 PM   #13
Default

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 by eng1; 8th June 2007 at 06:29 PM.
eng1 is offline  
Old 8th June 2007, 09:30 PM   #14
Default

Quote:
Originally Posted by eng1
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!

Far easier to do it with 8 bits in the first place!.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 9th June 2007, 04:00 AM   #15
Default

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 is online now  
Reply

Tags
display, lcd, pic, problem

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
PIC16F628A Reset? marting Micro Controllers 18 5th December 2008 09:31 PM
Need help with Intel Assembly Language and PIC16F877 avinsinanan Micro Controllers 10 4th March 2008 11:02 AM
Using Oscilloscopes mechie Electronic Theory 9 29th November 2007 10:49 PM
Multiple digits 7 segments display Joel Rainville Micro Controllers 44 22nd August 2005 09:22 PM
7 seg. display problem bluegirl Electronic Projects Design/Ideas/Reviews 8 18th April 2003 01:40 PM



All times are GMT. The time now is 06:10 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker