doug_h
Joined: 26 Feb 2004 Posts: 11
|
Best way of splitting LCD pins between ports? |
Posted: Mon Mar 29, 2004 10:01 am |
|
|
Hi all,
Quick qn., the LCD driver that ships with PICC uses a contiguous port to control the display. The code maps a struct over the the port like this:
Code: | // As defined in the following structure the pin connection is as follows:
// PORT_D_PIN LCD_Fn LCD_PIN#
// D0 Enable 6
// D1 RS 4
// D2 R/W 5
// D4 DB4 11
// D5 DB5 12
// D6 DB6 13
// D7 DB7 14
//
// LCD pins DB0-DB3 are not used and PORT_D_PIN 3 is not used.
struct lcd_pin_map { // This structure is overlayed
BOOLEAN enable; // on to the 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 D0.
} lcd;
#byte lcd = 8 // This puts the entire structure
// on to port D (at address 8)
#define set_tris_lcd(x) set_tris_d(x)
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the second line
BYTE const LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};
// These bytes need to be sent to the LCD
// to start it up.
// The following are used for setting
// the I/O port direction register.
struct lcd_pin_map const LCD_WRITE = {0,0,0,0,0}; // For write mode all pins are out
struct lcd_pin_map const LCD_READ = {0,0,0,0,15}; // For read mode data pins are in
|
This all works fine, but I don't have an entire contiguous port available on my design, I need to split the pins between two ports. What is the best way to accomplish this?
Thanks. |
|