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.