Page 458 - Programming Microcontrollers in C
P. 458
Adding a Display 443
and the other DATA. This register is at address 0x2c3ffff0. The
following typedef and #define makes this location available to
the program.
typedef struct {
BYTE COMMAND :8;
BYTE DATA :8;
} Lcddrv;
#define LCDDRV (*(Lcddrv *)(0X2C3FFFF0))
Access to this memory area is through Chip Select number 3. This
Chip Select must be set up and enabled. The following initialization
function allows access to the above memory address. The chip select
control registers are not set to a specified value at reset. It is best to
put a specified value into this register, 0, and then set the necessary
bits. The first two lines of code in the following function put a zero
into the address CS3CR. The fields in the chip select control register
allows insertion of wait states from 0 to 15. Fifteen was used here
because the memory location is rarely accessed; when accessed, it
deals with the outside world, and the long wait state will not
appreciably degrade the computer performance. An extra dead cycle
is added when there is a write to this address. The access is to a 16
bit port. The last instruction enables the chip select number 3.
/* set up memory to access the LCD */
void initperip(void)
{
UWORD *CS3CRX=(UWORD *)&CS3CR;
*CS3CRX=0; /* zero the whole register */
CS3CR.WSC=3; /* 3 wait states */
CS3CR.EDC=ON; /* extra dead cycle on write */
CS3CR.EBC=ON; /* enable byte write access only */
CS3CR.DSZ=2; /* 16 bit port */
CS3CR.CSEN=ON; /* chip select enabled */
}
There are two output functions that are useful. These functions are:
/* Routines for the LCD Display */
/* send a command to the LCD */
void LCDCommand(BYTE command)

