PDA

View Full Version : PIC16f690 LCD Not Working



hhosteam
- 3rd May 2009, 23:11
Hello all,
I'm new to Pic Programming and need some help!
I would like to learn how to display text on a HD44780.

at this time I'm using a PIC16f690 using the Conections listed below:

D4 - PortA.0
D5 - PortA.1
D6 - PortA.2
D7 - PortA.3
RS Pin4 - PortA.4 ( 10K pull up) also tried it with out pull up and get the same thing

Enable Pin6 - PortB.6
VO Pin3 - 10k pot
R/W Pin5 Connected to Ground

After start up I just get Black Blocks on line 2.
I got this code from the Book "Picbasic Projects 30 Projects using Pic Basic"
The only thing that I changed was the Define for Enable. I had to change it to use Portb.6 because the Pic16f690 does not have a pin b.3.

Please help
Here is the Code:

DEFINE LCD_DREG PORTA 'SET THE DATA PORT

DEFINE LCD_DBIT 4 'Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTA ' Set LCD Register Select port
DEFINE LCD_RSBIT 4 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 6 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD

Cnt VAR Word
'CMCON = 7 'THIS DOES NOT WORK WITH THE PIC 16F690
TRISA = 0
TRISB = 0
PAUSE 500
Cnt = 0
LCDOUT $FE,1

RPT:
LCDOUT $FE,2
LCDOUT "CNT=",DEC CNT
PAUSE 1000
Cnt = Cnt +1
GOTO RPT
END

mister_e
- 3rd May 2009, 23:21
1. PortA Doesn't Work http://www.picbasic.co.uk/forum/showthread.php?t=561
2. Look in your datasheet for ANSEL and ANSELH registers.
3. All Digital http://www.picbasic.co.uk/forum/showthread.php?t=11100


'CMCON = 7 'THIS DOES NOT WORK WITH THE PIC 16F690
Sure, this PIC don't have CMCON register, check the datasheet under Voltage Comparator section.

hhosteam
- 4th May 2009, 17:34
Thanks for the fast reply!
Again I’m new at this so please be patient with me on this.
I changed the code that the data lines use PortC instead of Port A.
I also added the following to change the pins to all digital
POKE ANSEL,0
poke ANSELH,0
is this the correct usage?

mister_e
- 4th May 2009, 20:41
Yes it is correct, but if you're using PBP you don't really need to use Peek/Poke.

ANSEL = 0
ANSELH = 0

The above will do the job.

Archangel
- 4th May 2009, 21:36
These should do for 16f690

ANSEL = 0
ANSELH = 0
CM1CON0 = 0
CM2CON0 = 0

hhosteam
- 6th May 2009, 12:27
Ok, I made the changes and I'm still having the same problem.
I attached the schematic and the code is listed below:
[CODE]
DEFINE LCD_DREG PORTC 'Set port C for the data lines
DEFINE LCD_DBIT 4

DEFINE LCD_RSREG PORTB 'Set the RS Port and Pin
DEFINE LCD_RSBIT 5

DEFINE LCD_EREG PORTB 'Set LCD Enable bit and pin
DEFINE LCD_EBIT 6

DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
' Set command delay time in us
DEFINE LCD_COMMANDUS 2000
' Set data delay time in us
DEFINE LCD_DATAUS 50

ANSEL = 0
ANSELH = 0
CM1CON0 = 0
CM2CON0 = 0

Cnt VAR WORD

'Start Program
poke TRISC,0
poke TRISB,0

Pause 500

cnt=0
RPT:
HIGH PORTB.6
LCDOUT $FE,1 'CLEAR LCD SCREEN
LCDOUT "CNT=", DEC CNT
Pause 1000
CNT=CNT+1
GOTO RPT
END
[CODE/]

mister_e
- 6th May 2009, 15:43
DEFINE LCD_DREG PORTC 'Set port C for the data lines
DEFINE LCD_DBIT 0
And you should try to use a pot on the contrast pin. As it is right now, and depending of your LCD module, you may have only black boxes instead of characters.

hhosteam
- 6th May 2009, 21:24
I did have a 10k pot on the contrast pin, I just wanted to remove it while I was testing it out. I will try again when I get home.
Thanks again,

hhosteam
- 8th May 2009, 05:09
Still have the same problem, any other ideas?

Archangel
- 8th May 2009, 06:51
Are you using this chip on a solderless breadboard or are you using the Low Pin Count Demo Board from Microchip ?
this is you code with only minor tweeks and it works on a solderless breadboard. try grounding the contrast pin #3 on the lcd. This is compiled using MPASM as it is what I always use.


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF &_CP_OFF
define OSC 4
DEFINE LCD_DREG PORTC 'Set port C for the data lines
DEFINE LCD_DBIT 4

DEFINE LCD_RSREG PORTB 'Set the RS Port and Pin
DEFINE LCD_RSBIT 5

DEFINE LCD_EREG PORTB 'Set LCD Enable bit and pin
DEFINE LCD_EBIT 6

DEFINE LCD_BITS 4
' Set number of lines on LCD
DEFINE LCD_LINES 2
' Set command delay time in us
DEFINE LCD_COMMANDUS 2000
' Set data delay time in us
DEFINE LCD_DATAUS 50

ANSEL = 0
ANSELH = 0
CM1CON0 = 0
CM2CON0 = 0

Cnt VAR WORD

'Start Program
TRISC = 0
TRISB = 0

Pause 500

cnt=0
RPT:
HIGH PORTB.6
LCDOUT $FE,1 'CLEAR LCD SCREEN
pause 500
LCDOUT $FE,2,"CNT=", DEC CNT
Pause 1000
CNT=CNT+1
GOTO RPT
END

flotulopex
- 27th May 2009, 19:48
I applied Joe's code and still can't bring my display to work with this chip (I tried with three).

Never had problems with other chips.

Don't know what's wrong :-/

Archangel
- 28th May 2009, 01:36
I applied Joe's code and still can't bring my display to work with this chip (I tried with three).

Never had problems with other chips.

Don't know what's wrong :-/
What are you getting Roger ? Blocks , anything ?

Archangel
- 28th May 2009, 05:54
Checked it again, and it's fine. here is the hex:

flotulopex
- 28th May 2009, 07:58
Sorry, I'm wrong, it worked for me too.. in the past, also with 16F690.

I may have a problem with my breadboards. Gonna buy a new one today.

Nevertheless, what I see on my LCD display is on it's first line, a row of blocks, slightly visible.

Of course, I tried to change the contrast, but nothing helps.

Archangel
- 28th May 2009, 08:01
Sorry, I'm wrong, it worked for me too.. in the past, also with 16F690.

I may have a problem with my breadboards. Gonna buy a new one today.

Nevertheless, what I see on my LCD display is on it's first line, a row of blocks, slightly visible.

Of course, I tried to change the contrast, but nothing helps.I never use a contrast pot, I ground pins 1,3,5,16, put power on 2,15 always works for me. Those breadboards get nasty inside, corrosion after the plating wears a bit, the component pins wear the contacts quickly too.

flotulopex
- 28th May 2009, 10:24
No pot on my side too.

I use a 1k2 to 2k2 resitor instead.

Must be the breadboards...

hhosteam
- 29th May 2009, 05:00
Still not working!
Just get a row of black blocks.

any one else able to get this working yet?

Archangel
- 29th May 2009, 05:44
Still not working!
Just get a row of black blocks.

any one else able to get this working yet?
Just a row of blocks indicates either contrast is too far + or no pic signal. Not meaning to offend or agitate, but you did look at the pic pinout in the data sheet, yes? I ask because this PIC has a somewhat convoluted pin arrangement and it is easy to wire it incorrectly. Is your programmer up to this chips needs? Most PICs like 16F84, 16F628 . .. have power in the center of the device but this has them swapped side for side and at 1 end, your programmer might not know this. I programmed mine using PICKitII and low parts count demo board made for 16F690. You might have to set up for ICSP to properly program it.

flotulopex
- 29th May 2009, 23:24
I just found what was bothering me: wrong oscillator fuse setting.

Couldn't see this for hours.....

Archangel
- 3rd June 2009, 06:26
I just found what was bothering me: wrong oscillator fuse setting.

Couldn't see this for hours.....
It seems the more simple the problem is, the better it's ability to hide.