This is kind of a follow up post to Using 2 Different Ports for the Same Input post by me (beeson76). That post contains the main program and this post contains the LCD.c program.
I have an LCD program that is from the samples directory of Hi-Tech complier. I would like to get all communication with the LCD and outputs on PORTC. Here is the program. As you can see the program uses both PORTA and PORTC. PORTA for communication with the LCD and PORTC with OUTPUT.
I would like for
LCD_EN to be RC0
LCD_RS to be RC1
LCD_RW to be RC2
and I would like for DB4-DB7 of the LCD inputs to be RC4-RC7.
Thanks for any help. Appreciate it very much.
I have an LCD program that is from the samples directory of Hi-Tech complier. I would like to get all communication with the LCD and outputs on PORTC. Here is the program. As you can see the program uses both PORTA and PORTC. PORTA for communication with the LCD and PORTC with OUTPUT.
Rich (BB code):
#include "htc.h"
#include "lcd.h"
void pause(unsigned short usvalue);
#define LCD_RS RA2
#define LCD_RW RA4
#define LCD_EN RA1
#define LCD_DATA PORTC
#define LCD_STROBE() ((LCD_EN = 1),(LCD_EN = 0))
void
lcd_write (unsigned char c)
{
pause (1);
LCD_DATA = ((c >> 4) & 0x0F);
LCD_STROBE();
LCD_DATA = (c & 0x0F);
LCD_STROBE();
}
void
lcd_clear(void)
{
LCD_RS = 0;
lcd_write (0x1);
pause(2);
}
void
lcd_puts(const char *s)
{
LCD_RS = 1;
while (*s)
lcd_write(*s++);
}
void
lcd_putch(char c)
{
LCD_RS = 1;
lcd_write(c);
}
void
lcd_goto(unsigned char pos)
{
LCD_RS = 0;
lcd_write (0x80 + pos);
}
void
lcd_init()
{
char init_value;
// ANSEL = 0;
init_value = 0x3;
TRISA = 0;
TRISC = 0;
LCD_RS = 0;
LCD_EN = 0;
LCD_RW = 0;
pause(15);
LCD_DATA = init_value;
LCD_STROBE();
pause(10);
LCD_STROBE();
pause(10);
LCD_STROBE();
pause(10);
LCD_DATA = 2;
LCD_STROBE();
lcd_write (0x28);
lcd_write (0xF);
lcd_clear();
lcd_write(0x6);
}
void lcd_putint (int i)
{
LCD_RS = i;
lcd_write(i);
}
I would like for
LCD_EN to be RC0
LCD_RS to be RC1
LCD_RW to be RC2
and I would like for DB4-DB7 of the LCD inputs to be RC4-RC7.
Thanks for any help. Appreciate it very much.