View previous topic :: View next topic |
Author |
Message |
anandpv2009
Joined: 26 Jul 2009 Posts: 31
|
LCD problem |
Posted: Sun Nov 29, 2009 10:35 am |
|
|
I am using a 20x4 lcd, it works fine with PIC16F877A with the below program
But not with PIC18F4520 and PIC18F4550
Code: | #include<18F4520.h> //#include<18F4550.h>
#fuses HS,NOLVP,NOWDT
#use delay(clock=20M)
#include<LCD420.C >
void main()
{
lcd_init();
delay_ms(100);
output_high(pin_b3);
printf(lcd_putc,"test");
while(true);
} |
I tested the above program with PIC18F2550 PIC18F4520 with the same PIC16F877a arrangement.
Anyone know the reason.. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 29, 2009 12:26 pm |
|
|
1. Post a list of the pin connections between the PIC and the LCD.
2. Post your compiler version.
3. Are you doing this testing in Proteus ? |
|
|
anandpv2009
Joined: 26 Jul 2009 Posts: 31
|
|
Posted: Sun Nov 29, 2009 12:43 pm |
|
|
B0 enable
B1 rs
B2 rw
B3 I am using this pin to turn on/off back light (through transistor)
B4 D4
B5 D5
B6 D6
B7 D7
16th pin of LCD - vdd
15th PIC of LCD - vss (The back light pin connection is not same as others)
compiler version
IDE 4.057
PC 4.068
PCM 4.068
PCH 4.068
PCD 4.057
I am using real circuit. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 29, 2009 12:58 pm |
|
|
Quote: | struct lcd_pin_map { // This structure is overlayed
BOOLEAN enable; // on to an I/O port to gain
BOOLEAN rs; // access to the LCD pins.
BOOLEAN rw; // The bits are allocated from
BOOLEAN unused; // low order up. ENABLE will
int data : 4; // be pin B0.
} lcd;
#byte lcd = 6 // This puts the entire structure
|
In your version of the compiler, the lcd420 driver is hard-coded to use
the port address for the 16F-series PICs, as shown by the line in bold.
The 18F PICs use a different address, and that is why your code does
not work.
In later versions of the compiler, the line shown below is used.
It will get the actual address used by the specified PIC (16F or 18F).
Code: | #locate lcd = getenv("SFR:PORTB") |
|
|
|
anandpv2009
Joined: 26 Jul 2009 Posts: 31
|
|
Posted: Sun Nov 29, 2009 1:06 pm |
|
|
Thanks for fast reply..
How I can correct this problem... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Nov 29, 2009 1:21 pm |
|
|
Start by reading my post. |
|
|
anandpv2009
Joined: 26 Jul 2009 Posts: 31
|
|
Posted: Sun Nov 29, 2009 1:28 pm |
|
|
I didn't find the port address for PIC18F4550 (in data sheet and devices folder of CCS)...
Where can i get it... |
|
|
anandpv2009
Joined: 26 Jul 2009 Posts: 31
|
|
Posted: Sun Nov 29, 2009 1:52 pm |
|
|
Thank uuuuuuuuuuuuuu sir...
Finally i found it
addr of PORTB is 0xF81 .....Ha Ha...
Now it works fine.......... |
|
|
Guest
|
|
Posted: Sun Nov 29, 2009 3:00 pm |
|
|
Thank u anand and PCM programmer.........
Yes it works |
|
|
|