Picdem™ 17 demonstration board user’s guide – Arizona Picdem 17 User Manual

Page 60

Advertising
background image

PICDEM™ 17 Demonstration Board User’s Guide

DS39024B-page 54

2001 Microchip Technology Inc.

#else

// Lower nibble

interface

data |= DATA_PORT&0x0f;

// Read the lower

nibble of data

#endif

E_PIN = 0;

RS_PIN = 0;

// Reset the control

bits

RW_PIN = 0;

#endif

return(data);

// Return the data

byte

}

/

*******************************************************************

*

* Function Name:

WriteDataXLCD

* Return Value:

void

* Parameters:

data: data byte to be written to LCD

* Description:

This routine writes a data byte to the

*

Hitachi HD44780 LCD controller. The user

*

must check to see if the LCD controller is

*

busy before calling this routine. The data

*

is written to the character generator RAM or

*

the display data RAM depending on what the

*

previous SetxxRamAddr routine was called.

*******************************************************************

*/

void WriteDataXLCD(static char data)

{

while(BusyXLCD());

#ifdef BIT8

// 8-bit interface

TRIS_DATA_PORT = 0;

// Make port output

DATA_PORT = data;

// Write data to port

RS_PIN = 1;

// Set control bits

RW_PIN = 0;

DelayFor18TCY();

E_PIN = 1;

// Clock data into

LCD

DelayFor18TCY();

E_PIN = 0;

RS_PIN = 0;

// Reset control

bits

TRIS_DATA_PORT = 0xff;

// Make port input

#else

// 4-bit interface

#ifdef UPPER

// Upper nibble

interface

TRIS_DATA_PORT &= 0x0f;

DATA_PORT &= 0x0f;

DATA_PORT |= data&0xf0;

#else

// Lower nibble

interface

TRIS_DATA_PORT &= 0xf0;

DATA_PORT &= 0xf0;

DATA_PORT |= ((data>>4)&0x0f);

#endif

RS_PIN = 1;

// Set control bits

RW_PIN = 0;

Advertising