View previous topic :: View next topic |
Author |
Message |
aryio
Joined: 29 Oct 2012 Posts: 2
|
LCD problem in PIC18F452 |
Posted: Mon Oct 29, 2012 11:55 am |
|
|
Hello,
I want to connect LCD 2*16 but microcontroller PIC18F452 does not work.
The codes are
Code: |
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000)
#include <lcd.c>
#define LCD_ENABLE_PIN PIN_C0
#define LCD_RS_PIN PIN_C1
#define LCD_RW_PIN 1
#define LCD_DATA4 PIN_D4
#define LCD_DATA5 PIN_D5
#define LCD_DATA6 PIN_D6
#define LCD_DATA7 PIN_D7
void main()
{
lcd_init(); // Always call this first.
lcd_putc("\fHello World\n");
lcd_putc("Line Number 2");
do{
output_high(PIN_B2);
Delay_ms(1000);
output_low(PIN_B2);
Delay_ms(1000);
}while(1);
}
|
Hardware is correct because it is ok with MikroC Pro. When I erase the codes that related to lcd, led works good (pin B2 is connected to led).
What is problem?
Thanks a lot |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Mon Oct 29, 2012 12:15 pm |
|
|
Hint.
How is lcd.c, going to know about your pin definitions?....
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Oct 29, 2012 2:23 pm |
|
|
See this thread for more information about how to use the CCS lcd driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=47663
Note that a pin constant must be specifed for LCD_RW_PIN. This is
shown in the link above. (Don't use #define LCD_RW_PIN 1 ).
Also, it appears that you are trying to mix the CCS lcd.c driver with the
example code for the Flex lcd driver (in the Code library forum).
You can do that, and it will work. But just remember that these are
two separate lcd drivers. The CCS driver is called lcd.c and the flex
driver is called flex_lcd.c.
The CCS lcd.c driver is in this directory. I assume your program uses
this driver:
c:\program files\picc\drivers\lcd.c
The Flex lcd driver is at this link:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
They are different drivers and require different #define statements for
the pins. |
|
|
aryio
Joined: 29 Oct 2012 Posts: 2
|
|
Posted: Tue Oct 30, 2012 1:32 am |
|
|
thanks for your kind support.
yes my problem was RW pin of LCD i had tied it to ground but again i connected it to micro and it is ok.
i think for understanding about this problem i should look at lcd.c section of RW of the LCD.
thanks |
|
|
|