Lcd.c description – Arizona Picdem 17 User Manual

Page 55

Advertising
background image

2001 Microchip Technology Inc.

DS39024B-page 49

LCD.C

Description

#else

// Lower nibble

interface

DATA_PORT &= 0xf0;

// Write lower nib-

ble

DATA_PORT |= (CGaddr&0x0f);

#endif

DelayFor18TCY();

E_PIN = 1;

// Clock cmd and

address in

DelayFor18TCY();

E_PIN = 0;

#ifdef UPPER

// Upper nibble

interface

TRIS_DATA_PORT |= 0xf0;

// Make inputs

#else

// Lower nibble

interface

TRIS_DATA_PORT |= 0x0f;

// Make inputs

#endif

#endif

return;

}

/

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

*

* Function Name:

SetDDRamAddr

* Return Value:

void

* Parameters:

CGaddr: display data address

* Description:

This routine sets the display data address

*

of the Hitachi HD44780 LCD controller. The

*

user must check to see if the LCD controller

*

is busy before calling this routine.

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

*/

void SetDDRamAddr(static unsigned char DDaddr)

{

while(BusyXLCD());

#ifdef BIT8

// 8-bit interface

TRIS_DATA_PORT = 0;

// Make port output

DATA_PORT = DDaddr | 0b10000000;

// Write cmd and

address to port

RW_PIN = 0;

// Set the control

bits

RS_PIN = 0;

DelayFor18TCY();

E_PIN = 1;

// Clock the cmd and

address in

DelayFor18TCY();

E_PIN = 0;

DelayFor18TCY();

TRIS_DATA_PORT = 0xff;

// Make port input

#else

// 4-bit interface

#ifdef UPPER

// Upper nibble

interface

TRIS_DATA_PORT &= 0x0f;

// Make port output

DATA_PORT &= 0x0f;

// and write upper

nibble

DATA_PORT |= ((DDaddr | 0b10000000) & 0xf0);

Advertising