Hi All,

Wow, it has been awhile since I've been here. Finally getting back into PIC's and I'm making a serial backpack using a 16F1503. I've managed to make one successfully in 4-bit mode using RC0-3 connected to LCD pins DB4-7. Being a glutton for punishment, I'm now trying to make a backpack for those nifty RGB character LCD's. To do this, I've attempting to use RA0-3 connected to DB4-7 because I need the PWM pins free on the C port. The problem is, the PIC doesn't seem to communicate to the LCD when I do this.

I've checked my connections and code multiple times and I've been reviewing the datasheet (did discover I hadn't disabled the comparators or DAC - fixed this, but still no dice). I'm having the code step through a few different colors on the LCD, so I can see the colors change and confirm that portion is working. The top line (2 x 16) will appear filled with blocks before the bottom one as I adjust the contrast to one extreme. I take this to mean the LCD thinks it is in one-line mode so no communication between the PIC and LCD.

I did connect the LCD to my original backpack circuit where RC0-3 is connected to data lines and the LCD works fine - text is displayed. The problem seems to be using RA0-3 to communicate to the data lines.

Anyone happen to use RA0-3 on a 16F1503 to communicate with an LCD in 4-bit mode? Am I missing a config or register setting somewhere?

RA0 connected to DB4
RA1 connected to DB5
RA2 connected to DB6
RA3 connected to DB7
RC0 connected to Register Select
RC2 connected to Enable
R/W connected to GND

Code:
  #CONFIG
    __config _CONFIG1, _FOSC_INTOSC & _MCLRE_OFF & _CP_ON & _CLKOUTEN_OFF
    __config _CONFIG2, _LVP_OFF & _LPBOR_OFF
  #ENDCONFIG

DEFINE OSC 16                               ' Let PBP clock speed will be 16MHz
OSCCON = $7B                                ' Use internal oscillator and set to 16MHz
DEFINE LCD_DREG PORTA                       ' Use Port A for LCD data
DEFINE LCD_DBIT 0                           ' Use RA0-RA3 for LCD data
DEFINE LCD_RSREG PORTC                      ' Use Port C for register select connection to LCD
DEFINE LCD_RSBIT 0                          ' Use RC0 for register select connection to LCD
DEFINE LCD_EREG PORTC                       ' Use Port C for enable connection to LCD
DEFINE LCD_EBIT 2                           ' Use RC2 for enable connection to LCD
DEFINE LCD_BITS 4                           ' Use 4-bit bus to communicate with LCD
DEFINE LCD_LINES 2                          ' Set number of lines on LCD to two (or more)
DEFINE LCD_COMMANDUS 1500                   ' Set LCD command delay time to 1500us
DEFINE LCD_DATAUS 44                        ' Set LCD data delay time to 44us
DEFINE SER2_BITS 8                          ' Set serin2 command as 8 bits, no parity

OPTION_REG.7 = 0                            ' Enable individual control of weak pull-ups
WPUA.0 = 0                                  ' Disable weak pull-up on RA0
WPUA.1 = 0                                  ' Disable weak pull-up on RA1
WPUA.2 = 0                                  ' Disable weak pull-up on RA2
WPUA.3 = 0                                  ' Disable weak pull-up on RA3
WPUA.4 = 1                                  ' Enable weak pull-up on RA4
WPUA.5 = 1                                  ' Enable weak pull-up on RA5

ANSELA = $00                                ' Set all ADC pins as digital only
ANSELC = $00                                ' Set all ADC pins as digital only
ADCON0 = $00                                ' Disable all ADC's
DACCON0.7 = 0                               ' Disable DAC
CM1CON0.7 = 0                               ' Disable comparator 1
CM2CON0.7 = 0                               ' Disable comparator 2

TRISA = %00110000                           ' Set RA0-RA3 as outputs and RA4-RA5 as inputs
TRISC = %00010000                           ' Set RC0-RC3 & RC5 as outputs and RC4 as an input
baud VAR WORD                               ' Word-sized variable used to set baud rate of serial communication
baud = 0                                    ' Clear baud value to zero
baud_display VAR WORD                       ' Word-sized variable to show actual baud rate selected
baud_display = 0                            ' Clear baud_display variable to zero
duty_cycle VAR Byte                         ' Byte-sized variable used to set PWM duty cycle
LED VAR BYTE                                ' Byte-sized variable used to define which LED to control
PWM_freq VAR WORD                           ' Word-sized variable used to set PWM frequency
PWM_freq = 1000                             ' Set PWM frequency equal to 1kHz
data_in VAR BYTE[2]                         ' Byte-sized variable used to store incoming data
RED VAR PORTC.5                             ' Define pin RC5 as RED (LED)
GREEN VAR PORTC.3                           ' Define pin RC3 as GREEN (LED)
BLUE VAR PORTC.1                            ' Define pin RC1 as BLUE (LED)
RX VAR PORTC.4                              ' Define pin RC4 as RX
PAUSE 500                                   ' Wait 500ms for LCD to initialize
'****************************************************************
Initialize:                                 ' Read switch inputs to determine baud rate
    IF PORTA.4 = 0 THEN                     ' If switch position one is low, then
        IF PORTA.5 = 0 THEN                 ' If switch position two is also low, then
            baud = 396                      ' Set baud rate to 2400
            baud_display = 2400             ' Set baud display to 2400
        ELSE                                ' If switch position one is low and switch position two is high, then
            baud = 188                      ' Set baud rate to 4800
            baud_display = 4800             ' Set baud display to 4800
        ENDIF                               ' End second if statement
    ELSE                                    ' Otherwise assume switch position one is high and
        IF PORTA.5 = 0 THEN                 ' If switch one is high and switch two is low, then
            baud = 84                       ' Set baud rate to 9600
            baud_display = 9600             ' Set baud display to 9600
        ELSE                                ' If switch one is high and switch two is high, then
            baud = 32                       ' Set baud rate to 19200
            baud_display = 19200            ' Set baud display to 19200
        ENDIF                               ' End second if statement
    ENDIF                                   ' End first if statement
HIGH RED                                    ' Turn on red LED backlight
LOW GREEN                                   ' Turn off green LED backlight
LOW BLUE                                    ' Turn off blue LED backlight
LCDOUT $FE, $01                             ' Clear LCD
PAUSE 30                                    ' Wait 30ms to allow screen to clear
LCDOUT $FE, $80, "Test line 1"              ' Display message at beginning of first line of LCD
LCDOUT $FE, $C0, "Test line 2"              ' Display message at beginning of second line of LCD
PAUSE 1000                                  ' Wait 1 second
LOW RED                                     ' Turn off red LED backlight
HIGH GREEN                                  ' Turn on green LED backlight
PAUSE 1000                                  ' Wait 1 second
LOW GREEN                                   ' Turn off green LED backlight
HIGH BLUE                                   ' Turn on blue LED backlight
PAUSE 1000                                  ' Wait 1 second
HIGH RED                                    ' Turn on red LED backlight
PAUSE 1000                                  ' Wait 1 second
LOW BLUE                                    ' Turn off blue LED backlight
HIGH GREEN                                  ' Turn on green LED backlight
PAUSE 1000                                  ' Wait 1 second
LOW RED                                     ' Turn off red LED backlight
HIGH BLUE                                   ' Turn on blue LED backlight
PAUSE 1000                                  ' Wait 1 second
HIGH RED                                    ' Turn on red LED backlight
PAUSE 1000                                  ' Wait 1 second
LOW RED                                     ' Turn off red LED backlight
LOW BLUE                                    ' Turn off blue LED backlight
LCDOUT $FE, $01                             ' Clear LCD
PAUSE 30                                    ' Wait 30ms to allow screen to clear