View previous topic :: View next topic |
Author |
Message |
noplacelikehome
Joined: 23 Nov 2005 Posts: 4
|
LCD.C Driver Question |
Posted: Wed Nov 23, 2005 7:30 pm |
|
|
I'm a TOTAL newbie to the PIC 16f877. the LCD driver provided by CCS is to be used on PORT B and PORT D (see below). BUT, I'm currently using PORT B for something else. Can I switch to PORT C? From the 16f877 datasheet I noticed that there is no 'option_reg' for PORT C, are there any alternatives? HELP!! Thanks.
--------------------------------------------------------------------
#if defined(__PCH__)
#if defined use_portb_lcd
#byte lcd = 0xF81 // This puts the entire structure
#else
#byte lcd = 0xF83 // This puts the entire structure
#endif
#else
#if defined use_portb_lcd
#byte lcd = 6 // on to port B (at address 6)
#else
#byte lcd = 8 // on to port D (at address 8)
#endif
#endif
#if defined use_portb_lcd
#define set_tris_lcd(x) set_tris_b(x)
#else
#define set_tris_lcd(x) set_tris_d(x)
#endif
-------------------------
Also, my LCD has 4 lines. Can the code be modified to:
#define lcd_type 4
#define lcd_line_two 0x40 // LCD RAM address for the 2nd line
#define lcd_line_three 0x10 //LCD RAM address for 3rd line
#define lcd_line_four 0x50 //LCD RAM address for 4th line
void lcd_gotoxy( BYTE x, BYTE y)
{
BYTE Data;
if(y=2)
Data=lcd_line_two;
else if (y=3)
Data=lcd_line_three;
else if (y=4)
Data=lcd_line_four;
else
Data=0;
Data+=x-1;
lcd_send_byte(0,0x80|Data);
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 23, 2005 11:07 pm |
|
|
Quote: | Can I switch to PORT C? |
CCS has a 4x20 lcd driver, called LCD420.C, and it's in this folder:
C:\Program Files\PICC\Drivers
It's setup to run on Port B, but you can make the following changes
to let it run on Port C.
1. Change the lcd port address statement from:
#byte lcd = 6
to
#byte lcd = 7 // Port C for the 16F877
2. There are three places where it uses the set_tris_b() function.
Just change it to "set_tris_c" in each statement, and leave everything
else the same. |
|
|
noplacelikehome
Joined: 23 Nov 2005 Posts: 4
|
|
Posted: Sun Nov 27, 2005 1:17 am |
|
|
Thanks! |
|
|
|