Hello guys!
I have a small problem again and it is driving me nuts. I am trying to interface a pic16f690 with a LCD (Hitachi 44780). But I only get black boxes on my screen. I have been searching the whole internet but didn't find any results.
I used this tutorial (http://www.pyroelectro.com/tutorials/pic_lcd/schematic.html) as a basic start and used his code(see below). I have connected RS to RC7, RW to RC6 and E to RC5 and port D4 tot D7 to PORTB of the pic for 4 bit communication.
I don't think it is a contrast problem, since i have connected a 10k pot between the VCC en VO pin. When i turn down the pot the black boxes only get less visible. I checked all the connection a hundred times, so that wont be the problem also.
I really hope someone can help me!
Thanks!
I have a small problem again and it is driving me nuts. I am trying to interface a pic16f690 with a LCD (Hitachi 44780). But I only get black boxes on my screen. I have been searching the whole internet but didn't find any results.
I used this tutorial (http://www.pyroelectro.com/tutorials/pic_lcd/schematic.html) as a basic start and used his code(see below). I have connected RS to RC7, RW to RC6 and E to RC5 and port D4 tot D7 to PORTB of the pic for 4 bit communication.
I don't think it is a contrast problem, since i have connected a 10k pot between the VCC en VO pin. When i turn down the pot the black boxes only get less visible. I checked all the connection a hundred times, so that wont be the problem also.
I really hope someone can help me!
Thanks!
Rich (BB code):
#include <htc.h>
#include <pic.h>
#include <pic16f690.h>
#define RS_PIN PORTCbits.RC7 /* PORT for RS */
#define RW_PIN PORTCbits.RC6 /* PORT for RW */
#define E_PIN PORTCbits.RC5 /* PORT for E */
unsigned char counter=0;//Overflow counter
int count=0;
char output[] = " Hello";
char output2[] = "World";
void prnt(unsigned int);
void commd(unsigned int);
void lcd_init(void);
void main()
{
ANSEL = 0;
ANSELH=0;
TRISC=0; // PORTC = output
PORTC=0; // PORTC reset
TRISC=0x00;
TRISB=0x00;
PORTB=0x00;
PORTC=0x00;
__delay_ms(100);
lcd_init();
while(output[count] != '\0')
{
prnt(output[count]);
count++;
}
commd(0b11000000); //Move 2nd Next Line
count = 0;
while(output2[count] != '\0')
{
prnt(output2[count]);
count++;
}
commd(0b10000000);
while(1)
{
};
}
void lcd_init(void)
{
E_PIN = 0;
RS_PIN = 0;
RW_PIN = 0;
commd(0b00000010);
commd(0b00101000);
commd(0b00001100);
commd(0b00000001);
commd(0b00000010);
}
//4-bit print interface
void prnt(unsigned int character)
{
PORTB=character >> 4;
RS_PIN = 1;
E_PIN = 1;
__delay_ms(200);
E_PIN = 0;
RS_PIN = 0;
PORTB=character & 0x0f;
RS_PIN = 1;
E_PIN = 1;
__delay_ms(200);
E_PIN = 0;
RS_PIN = 0;
}
//4-bit instruction interface
void commd(unsigned int commd)
{
PORTB=commd >> 4;
E_PIN = 1;
E_PIN = 0;
PORTB=commd &0x0f;
E_PIN = 1;
E_PIN = 0;
__delay_ms(200);
}