Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - PIC and LCD Conflict on PORTC

(you are viewing a thread; or go back to list of threads)

PIC and LCD Conflict on PORTC (by zoe king)
I am working on a PIC project to connect it to a LCD in 4 bit mode. My data lines for my LCD are connected to my PORTC (PORTC0-3), but I need 4 pins from PORTC to connect to a 4 switches also (PORTC4-7). The PIC is a PIC16F886.(http://www.kynix.com/Detail/245629/PIC16F886.html) The code for my LCD.c is below.
/*Go to the Specified Position*/

void
lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write(0x80 + pos);
}

/*Initialize the LCD - put into 4 bit mode*/

void
lcd_init()
{
char init_value;

ANSEL = 0; //Disable Analog Pins on PORTA

init_value = 0x3;
TRISA = 0;
TRISC = 0;
LCD_RS = 0;
LCD_EN = 0;
LCD_RW = 0;

__delay_ms(15); //Wait 15ms after Power applies)
LCD_DATA = init_value;
LCD_STROBE();
__delay_ms(10);
LCD_STROBE();
__delay_ms(10);
LCD_STROBE();
__delay_ms(10);
LCD_DATA = 2; //Four Bit Mode
LCD_STROBE();

lcd_write(0x28); //Set Interface Length
lcd_write(0xF); //Display On, Cursor On, Cursor Blink
lcd_clear(); //Clear Screen
lcd_write(0x6); //Set Entry Mode
}
Is there any way to "break" up PORTC so I can use it for both the LCD and the switches.

Thanks for any help provided.
Tue Oct 25 2016, 05:40:53
(no subject) (by Ihor Nehrutsa)
TRISC = 0xF0; // PORTC0-3 output, PORTC4-7 input
Tue Oct 25 2016, 06:27:28
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):