Arizona 17 Network Card User Manual


 
PICDEM 17 Demonstration Board Users Guide
DS39024B-page 48 2001 Microchip Technology Inc.
/
*******************************************************************
*
* Function Name: SetCGRamAddr
* Return Value: void
* Parameters: CGaddr: character generator ram address
* Description: This routine sets the character generator
* address of the Hitachi HD44780 LCD
* controller. The user must check to see if
* the LCD controller is busy before calling
* this routine.
*******************************************************************
*/
void SetCGRamAddr(static unsigned char CGaddr)
{
while(BusyXLCD());
#ifdef BIT8 // 8-bit interface
TRIS_DATA_PORT = 0; // Make data port
ouput
DATA_PORT = CGaddr | 0b01000000; // Write cmd and
address to port
RW_PIN = 0; // Set control sig-
nals
RS_PIN = 0;
DelayFor18TCY();
E_PIN = 1; // Clock cmd and
address in
DelayFor18TCY();
E_PIN = 0;
DelayFor18TCY();
TRIS_DATA_PORT = 0xff; // Make data port
inputs
#else // 4-bit interface
#ifdef UPPER // Upper nibble
interface
TRIS_DATA_PORT &= 0x0f; // Make nibble input
DATA_PORT &= 0x0f; // and write upper
nibble
DATA_PORT |= ((CGaddr | 0b01000000) & 0xf0);
#else // Lower nibble
interface
TRIS_DATA_PORT &= 0xf0; // Make nibble input
DATA_PORT &= 0xf0; // and write upper
nibble
DATA_PORT |= (((CGaddr |0b01000000)>>4) & 0x0f);
#endif
RW_PIN = 0; // Set control sig-
nals
RS_PIN = 0;
DelayFor18TCY();
E_PIN = 1; // Clock cmd and
address in
DelayFor18TCY();
E_PIN = 0;
#ifdef UPPER // Upper nibble
interface
DATA_PORT &= 0x0f; // Write lower nib-
ble
DATA_PORT |= ((CGaddr<<4)&0xf0);