PDA

View Full Version : LCD problems when EBIT is changed



passion1
- 9th June 2007, 14:20
I am using a 28pin PIC16F73 (compatible with 16F877).

If I connect my pic to a LCD using PORTB pin 3 as the EBIT, my LCD works perfectly.

DEFINE LCD_DREG PORTA
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50


TRISB=0 ' PORTB is output
TRISA=0 ' PORTA is output

ADCON1 =7 ' PORTA is digital


However, I need PORTB to connect a keypad and if I now change the EBIT definition to PORTA pin5:

DEFINE LCD_EREG PORTA
DEFINE LCD_EBIT 5

and move the connection to RA5, then my LCD suddenly won't work?

I have tried anything but cannot understand why this is happening.

passion1
- 10th June 2007, 20:06
My circuit looks exactly like the one on p.96 of the PBP manual that shows the default setup for connecting a LCD. (except for the fact that I am using a pic16f73 and a 20MHz crystal).

Thus default connections for LCD.

Any help or suggestion is appreciated!

Archangel
- 10th June 2007, 22:19
My circuit looks exactly like the one on p.96 of the PBP manual that shows the default setup for connecting a LCD. (except for the fact that I am using a pic16f73 and a 20MHz crystal).

Thus default connections for LCD.

Any help or suggestion is appreciated!

This PIC has a lot of analog stuff, make sure to disable the comparators, and the Capture compare/PWM goodies, also check data sheet RE: SSP Module as that port is used for that , you may have to set registers to disable. Try CMCON = 7 to turn off the comparators.

BobK
- 11th June 2007, 02:35
Hi Passion1,

Did you add a pull up resistor to RA4? It is an open drain type of pin when used in the digital mode.

BobK

skimask
- 11th June 2007, 03:13
Hi Passion1,

Did you add a pull up resistor to RA4? It is an open drain type of pin when used in the digital mode.

BobK

That's true, but he's on RA5...

BobK
- 11th June 2007, 12:49
Hello,

Yes I did understand he is on RA5 and what he is using each pin for but wouldn't the lack of a pull up also affect the proper operation if he didn't have a high level on RA4?

BobK

skimask
- 11th June 2007, 13:34
Hello,

Yes I did understand he is on RA5 and what he is using each pin for but wouldn't the lack of a pull up also affect the proper operation if he didn't have a high level on RA4?

BobK

DOH! No kidding... RSREG is on RA4...duh.........
BUT...that would also mean that the LCD never worked in the first place.

Archangel
- 12th June 2007, 00:35
DOH! No kidding... RSREG is on RA4...duh.........
BUT...that would also mean that the LCD never worked in the first place.
That was my thinking, I assumed it was working with the e bit hooked to PortB and he only moved that.

passion1
- 12th June 2007, 21:36
I havenot yet find the reason why my RA5 connection would not work, but I found an alternative solution by using mister_e's keypad routines to connect my keypad to different ports. Thank you mister_e!

However, I still have a problem:
I have connected my 4x4 keypad to pin 4-7 of PORTB and PORTC and is using the following code to send the keypad output to the LCD:

DEFINE KEYPAD_ROW 4 ' 4 ROW keypad
DEFINE KEYPAD_ROW_PORT PORTC ' ROW port = PORTC
DEFINE KEYPAD_ROW_BIT 4 ' ROW0 = PORTC.4
DEFINE KEYPAD_COL 4 ' 4 COL keypad
DEFINE KEYPAD_COL_PORT PORTB ' COL port = PORTB
DEFINE KEYPAD_COL_BIT 4 ' COL0 = PORTB.4
DEFINE KEYPAD_DEBOUNCEMS 200 ' debounce delay = 200 mSec
DEFINE KEYPAD_AUTOREPEAT 1 ' use auto-repeat feature

PAUSE 500
LCDOUT $FE,1,"Initializing ...."
Pause 1000

INCLUDE "KeyPad.bas"
start:
@ READKEYPAD _myvar
lcdout $fe,1
lcdout " Key Value = ",DEC2 myvar
GOTO start

If I press a key on the keypad, then the correct key value is displayed, thus I know my keypad is connected right and working, BUT while no key is pressed on the keypad, different key values are being displayed as if a key was pressed, e.g. key value = 20, 13, 20, 05, 20, 09 .......
Every second value is a 20?
Why is this happening and how can I get rid of key values being read while no key was pressed?
Thanks for the help thusfar!

mister_e
- 12th June 2007, 21:39
mmm sounds like you miss to install the Pull-up resistors?

passion1
- 12th June 2007, 21:43
Steve

I have 270 ohm resistors on the 4 PORTC pins.

mister_e
- 12th June 2007, 21:44
Between the i/o and VCC?


EDIT:::: MIIP they have to be connected on PORTB, between i/o and VCC.

EDIT2:::: You could also try to use those internal...

OPTION_REG.7=

passion1
- 12th June 2007, 21:54
Steve

I will try moving the resistors to PORTB. Thanks.
Please excuse my ignorance but I do not understand what you mean with:

You could also try to use those internal...

Code:
OPTION_REG.7=

mister_e
- 12th June 2007, 22:10
Oups...
Add

OPTION_REG.7=0

At the top of your code, this should enable the internal Weak-pull-up on PORTB. Make sure you place this code line at least under the TRISB=xxxxxxxx line.. if there's any ;)

passion1
- 12th June 2007, 22:16
Steve

OPTION_REG.7=0

solved my problem! Thanks so much!!

mister_e
- 12th June 2007, 22:18
http://www.mister-e.org/Pics/woohoo

Enjoy!