CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

16f877A LCD interface

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
HOHOHAHA



Joined: 13 Apr 2007
Posts: 24

View user's profile Send private message AIM Address

16f877A LCD interface
PostPosted: Mon Sep 10, 2007 6:12 am     Reply with quote

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 ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Sep 10, 2007 11:24 am     Reply with quote

Check the pin connections on your board. Make sure they are correct.

Check the LCD driver file. Make sure the pin list is correct. Don't leave
the old pin settings in the driver. Delete the old #define statements
and just put in your new #define statements for the pins.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group