HOHOHAHA
Joined: 13 Apr 2007 Posts: 24
|
16f877A LCD interface |
Posted: Mon Sep 10, 2007 6:12 am |
|
|
hello , I am using 16f877A and trying to interface it with an LCD(2X16) HD44780 compatible. My CCS version is : 4.023. I used the driver posted by "PCM" (Flex_lcd.c), but used different config. pin.
Code: |
#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //Resistor/Capacitor Osc with CLKOUT
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include "LCD1.c"
void main()
{
long int i;
//char name;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
lcd_init();
set_tris_b(0x00);
while(1)
{
output_b(0x00);
lcd_putc("\fHello World !");
delay_ms(2000);
for(i=100;i<=255;i++)
{
printf(lcd_putc,"\fvalue %ld looks \nlike :%c",i,i);
delay_ms(700);
}
delay_ms(1000);
lcd_putc("\n Hello India !!");
output_b(0xff);
delay_ms(1000);
lcd_putc("\b");
delay_ms(1000);
}
}
|
Code: |
the PIN conf that I used was...
D0 - E
D1 - RS
D2 - R/W
D4 - D4
D5 - D5
D6 - D6
D7 -D7
|
BUT the problem arises here .... the LED(TRIS_B = 0x00) does not blink and I found that as I disconnect D0 of my PIC to LCD(enable) the program starts executing, but making the connection again D0 goes LOW and program stops executing.
But at last the everything was alright as I used the default PIn conf. given by PCM
Code: |
#define LCD_DB4 PIN_D0
#define LCD_DB5 PIN_D1
#define LCD_DB6 PIN_D2
#define LCD_DB7 PIN_D3
#define LCD_E PIN_A1
#define LCD_RS PIN_A3
#define LCD_RW PIN_A2
// If you only want a 6-pin interface to your LCD, then
// connect the R/W pin on the LCD to ground, and comment
// out the following line.
#define USE_LCD_RW 1
|
can any one plz explain what is the problem ? |
|