PDA

View Full Version : LCD RS bit wiring with 16F685



RCtech
- 30th May 2014, 11:04
Hi everybody.
After spending time since many days and looking everywhere on this forum and other, I don't find where is my mistake.
Below, y'oull se my working program if I connect the LCD Register Select bit on PORTA.4.
But... It's better for my PCB to connect it on PORTC.6.

If I do that, my LCD doesn't work and I don't know why.

Is there anyone who know ?

Here is the code :




@ device PIC16F685, intrc_osc_NOCLKOUT, wdt_off, pwrt_on, mclr_off, protect_off, bod_on
DEFINE NO_CLRWDT 1

Define OSC 4
INTCON = %10001000
OSCCON = %01100111
VRCON = 000000
ADCON0 = 000000

Define ADC_BITS 10
Define ADC_CLOCK 3
Define ADC_SAMPLEUS 50
ADCON0.7 = 1 ' Right justify result

ANSEL = %00000001 ' Set pin AN0 to AN7 (AN0) to analog input, the rest to digital (for future use)
ANSELH = %0000 ' Set pins AN8 to AN11

TrisA = 001111
TrisB = %00000000
TrisC = %11111111

Clear

LOW TRISA
LOW TRISB
LOW TRISC

Define LCD_COMMANDUS 2000
Define LCD_DATAUS 50

DEFINE LCD_DREG PORTB ' Set LCD Data on PORTB
DEFINE LCD_DBIT 4 ' Set starting Data bit on PORTB.4 (0 or 4) if 4-bit bus i.e, PortB.4-PORTB.7
DEFINE LCD_RSREG PORTA ' Set LCD Register Select on PORTA
DEFINE LCD_RSBIT 4 ' Set LCD Register Select bit on PORTA.4 (PORTA.3 is only in input mode)
DEFINE LCD_EREG PORTC ' Set LCD Enable on PORTC
DEFINE LCD_EBIT 7 ' Set LCD Enable bit on PORTC.7
DEFINE LCD_BITS 4 ' LCD in 4 bit mode
DEFINE LCD_LINES 4 ' 4 lines LCD display

Pause 500

AFF:

LCDOut $FE, 1 ' Clear the display
PAUSE 500
'----------LINE 1
LCDOut $FE, $80, "Line 1 for test"
PAUSE 1000
GOTO AFF

END



Now if I change

DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 4

to:

DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 6

and rewiring the RS pin to PORTC6 (Pin #8), it doesn't work.
I'm sure it's for a very simple reason but I don't find which one.

Thanx a lot for any help.

EarlyBird2
- 30th May 2014, 11:12
You have set

TrisC = %11111111

which makes PORTC6 an input. I would have thought it needs to be output for a LCD?

RCtech
- 30th May 2014, 11:21
You have set

TrisC = %11111111

which makes PORTC6 an input. I would have thought it needs to be output for a LCD?

Arrrg ! The only thing and the most simple I didn't checked !!
Sometimes, we are looking for things so far and what we want is just font of our eyes...
You're right, it was mistake. Now, everything is okay.

Thanx a lot EarlyBird2

EarlyBird2
- 30th May 2014, 11:24
Pleased I helped.