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 CCS Technical Support

16f876 and lcd

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



Joined: 16 Mar 2009
Posts: 29

View user's profile Send private message

16f876 and lcd
PostPosted: Mon May 09, 2011 12:11 pm     Reply with quote

Hi all

I'm trying to use a (working) lcd (20x2) with a 16f876. I have a 20Mhz quartz.

I see only the first line with all square.

DB4 - RA2
DB5 - RA0
DB6 - RA1
DB7 - RA4
RS - RB6
RW - RA3
E - RB7

main.c
Code:

#include <main.h>
#include "flex_lcd_16x1.c"

void main()

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   
   delay_ms(100);
   lcd_init();
   delay_ms(600);
   
   printf(lcd_putc, "\fABCDEFGHIJKLMNOPQRST");
   printf(lcd_putc, "\nabcdefghijklmnopqrst");
   
   delay_ms(2000);

   while(1)
   {
      output_high(PIN_B0);
      delay_ms(1000);
      output_low(PIN_B0);
      delay_ms(1000);
     
      printf(lcd_putc, "Test");
   }
}


main.h
Code:

#include <16F876.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES PUT                      //Power Up Timer
#FUSES NOBROWNOUT               //No brownout reset
#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
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOPROTECT                //Code not protected from reading

#use delay(clock=20000000)


Code:

#define LCD_DB4   PIN_A2
#define LCD_DB5   PIN_A0
#define LCD_DB6   PIN_A1
#define LCD_DB7   PIN_A4

#define LCD_RS    PIN_B6
#define LCD_RW    PIN_A3
#define LCD_E     PIN_B7


Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 09, 2011 12:17 pm     Reply with quote

Quote:
DB4 - RA2
DB5 - RA0
DB6 - RA1
DB7 - RA4
RS - RB6
RW - RA3
E - RB7

Pin A4 is open-drain on this PIC. It needs an external 4.7K pull-up
resistor on that pin, to operate as an output pin. The LCD has a pull-up
on the DB7 pin, but it's very weak. You should add the external 4.7K
pull-up to it.

Also, you're using pins B6 and B7 for the lcd. Those are the programmer
and debugger pins (for ICD2, ICD3, PicKit, ICD-U40, etc.). The lcd
won't run if the ICD is connected to the board. It's better if you use two
other pins for the lcd.

Quote:
I'm trying to use a (working) lcd (20x2) with a 16f876.
#include "flex_lcd_16x1.c"

Also, you are using the wrong Flex driver. You have a 2-line LCD.
I think the 16x2 Flex driver would work OK for your LCD:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
adalucio



Joined: 16 Mar 2009
Posts: 29

View user's profile Send private message

PostPosted: Tue May 10, 2011 2:11 am     Reply with quote

Thanks it worked

Very Happy Very Happy Very Happy
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