View previous topic :: View next topic |
Author |
Message |
pokiko
Joined: 27 Jul 2007 Posts: 33
|
writing to 16x2 LCD with pic18f2520 |
Posted: Fri Jul 27, 2007 8:16 am |
|
|
Hello
i have been unable to write'hello' to the hd44780 compatible 16x2 LCD over 4 bit by using pic18f2520. The pin configuration is like this:
portb LCD
RB7-------DB7
RB6-------DB6
RB5-------DB5
RB4-------DB4
RB3-------E
RB2-------RS
r/w pin is grounded.
RB0 VE RB1 have been used as output for another aim.
is there anybody who can give me an idea? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
pokiko
Joined: 27 Jul 2007 Posts: 33
|
|
Posted: Mon Jul 30, 2007 2:32 am |
|
|
Thank you for your help. I am new in CCS. I have made these following changes but i have been unable to write to LCD.
Code: |
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_E PIN_B3
#define LCD_RS PIN_B2
//#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
|
My code is here;
Code: |
#include <18F2520.h>
#FUSES NOWDT,INTRC_IO, NOPROTECT, NOBROWNOUT,NOPUT,NOLVP
#use delay(clock=20000000)
#define use_portb_lcd 1
#include "flex_LCD.c"
#use fast_io (B)
void main()
{
lcd_init();
printf(lcd_putc, "\f");
printf(lcd_putc, "Hello World! :)");
while(1);
}
|
could you tell me please where i am wrong? Thanks |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jul 30, 2007 2:42 am |
|
|
Quote: | #include <18F2520.h>
#FUSES NOWDT,INTRC_IO, NOPROTECT, NOBROWNOUT,NOPUT,NOLVP
#use delay(clock=20000000)
#define use_portb_lcd 1
#include "flex_LCD.c"
#use fast_io (B) |
1. The internal oscillator without the PLL (INTRC_IO fuse) can run at
8 MHz maximum. You have to specify the #use delay() value that is
the same speed as the oscillator is running. Change it to this:
Code: | #use delay(clock=8000000) |
2. The "Flex" driver doesn't use the "use_portb_lcd" constant.
Delete that line.
3. The "Flex" driver doesn't work with "fast_io" mode. Delete that line. |
|
![](templates/subSilver/images/spacer.gif) |
|