CFAX LCD and LPC2138(Finally an image-what about backlight?)

i finally managed to preview an image on the screen.

http://www.geocities.com/fgcity/finaly-image.jpg

I was wondering about the backlight.

It doesn’t say anything about the backlight operation of the header board on the website.

I understand that the backlight is on pin 31 (BL_EN). Is it enabled by just putting pin 31 to high? or is there any other code that must be done?

PS:

here is the code for the image if anyone want’s it(it’s basically a modification of the sample file. I took the HEX of images from CRYSTAL Fonts soursecode)

///////////////////////////

/*

  • Some example code for the CFAX LCD module using a Philips ARM LPC 2138 MCU.

  • This code contains functions to read and write the LCD memory, print characters,

  • and the read touch screen.

  • Compiled with GCC.

  • Spark Fun Electronics, Owen Osborn, 10-22-05

*/

/**********************************************************

Defines

**********************************************************/

#define LCD_ON 0xAF

/* *********************************************************

Function declarations

********************************************************* */

// these are for the LPC2138 internal initialization

void Initialize(void);

void feed(void);

void delay(void);

unsigned int get_LCD_port(unsigned char); // Parses data byte (D7:0) to appropriate IO pins

void LCD_out(unsigned char);

void RD(char stat); // sets / clears the various LCD control lines

void RW(char stat);

void BL_ON(char stat);

void RS(char stat);

void RSTB(char stat);

void LCD_init(void);

void LCD_command(unsigned char); // sends command to LCD

void LCD_write_data(unsigned char, unsigned char, unsigned char); // writes data to memory

void LCD_clear_screen(void);

void LCD_put_char(unsigned char character, unsigned char x, unsigned char y);

void LCD_print_string(char *nate, unsigned char x, unsigned char y);

//touch screen

void TS1(unsigned char);

void TS2(unsigned char);

void TS3(unsigned char);

void TS4(unsigned char);

//unsigned int adc_TS2(void);

//unsigned int adc_TS3(void);

void IRQ_Routine (void) attribute ((interrupt(“IRQ”)));

void FIQ_Routine (void) attribute ((interrupt(“FIQ”)));

void SWI_Routine (void) attribute ((interrupt(“SWI”)));

void UNDEF_Routine (void) attribute ((interrupt(“UNDEF”)));

/**********************************************************

Header files

**********************************************************/

#include “LPC213x.h” // this file contains the I/O definitions for the LPC2138 ARM

/**********************************************************

Global Variables

**********************************************************/

// these are the 5x8 ASCII characters starting with ’ '.

// these should probably be stored in flash or eeprom, but ram works for this simple program.

unsigned char characters =

{ \

0x0,0x0,0x0,0x0,0x0,\

0x0,0x0,0x4F,0x0,0x0,\

0x0,0x7,0x0,0x7,0x0,\

0x14,0x7F,0x14,0x7F,0x14,\

0x24,0x2A,0x7F,0x2A,0x12,\

0x23,0x13,0x8,0x64,0x62,\

0x00,0x02,0x05,0x02,0x00,\

0x0,0x5,0x3,0x0,0x0,\

0x1C,0x22,0x41,0x0,0x0,\

0x0,0x0,0x41,0x22,0x1C,\

0x14,0x8,0x3E,0x8,0x14,\

0x8,0x8,0x3E,0x8,0x8,\

0x0,0x50,0x30,0x0,0x0,\

0x8,0x8,0x8,0x8,0x8,\

0x0,0x60,0x60,0x0,0x0,\

0x20,0x10,0x8,0x4,0x2,\

0x3E,0x51,0x49,0x45,0x3E,\

0x0,0x42,0x7F,0x40,0x0,\

0x42,0x61,0x51,0x49,0x46,\

0x21,0x41,0x45,0x4B,0x31,\

0x18,0x14,0x12,0x7F,0x10,\

0x27,0x45,0x45,0x45,0x39,\

0x3C,0x4A,0x49,0x49,0x30,\

0x1,0x71,0x9,0x5,0x3,\

0x36,0x49,0x49,0x49,0x36,\

0x06,0x49,0x49,0x49,0x36,\

0x0,0x36,0x36,0x0,0x0,\

0x0,0x56,0x36,0x0,0x0,\

0x8,0x14,0x22,0x41,0x0,\

0x14,0x14,0x14,0x14,0x14,\

0x0,0x41,0x22,0x14,0x8,\

0x2,0x1,0x51,0x9,0x6,\

0x32,0x49,0x79,0x41,0x3E,\

0x7E,0x11,0x11,0x11,0x7E,\

0x7F,0x49,0x49,0x49,0x36,\

0x3E,0x41,0x41,0x41,0x22,\

0x7F,0x41,0x41,0x22,0x1C,\

0x7F,0x49,0x49,0x49,0x41,\

0x7F,0x9,0x9,0x9,0x1,\

0x3E,0x41,0x49,0x49,0x7A,\

0x7F,0x8,0x8,0x8,0x7F,\

0x0,0x41,0x7F,0x41,0x0,\

0x20,0x40,0x41,0x3F,0x1,\

0x7F,0x8,0x14,0x22,0x41,\

0x7F,0x40,0x40,0x40,0x40,\

0x7F,0x2,0xC,0x2,0x7F,\

0x7F,0x4,0x8,0x10,0x7F,\

0x3E,0x41,0x41,0x41,0x3E,\

0x7F,0x9,0x9,0x9,0x6,\

0x3E,0x41,0x51,0x21,0x5E,\

0x7F,0x9,0x19,0x29,0x46,\

0x46,0x49,0x49,0x49,0x31,\

0x1,0x1,0x7F,0x1,0x1,\

0x3F,0x40,0x40,0x40,0x3F,\

0x1F,0x20,0x40,0x20,0x1F,\

0x3F,0x40,0x38,0x40,0x3F,\

0x63,0x14,0x8,0x14,0x63,\

0x7,0x8,0x70,0x8,0x7,\

0x61,0x51,0x49,0x45,0x43,\

0x7F,0x41,0x41,0x0,0x0,\

0x2,0x4,0x8,0x10,0x20,\

0x0,0x0,0x41,0x41,0x7F,\

0x4,0x2,0x1,0x2,0x4,\

0x40,0x40,0x40,0x40,0x40,\

0x0,0x1,0x2,0x4,0x0,\

0x20,0x54,0x54,0x54,0x78,\

0x7F,0x48,0x44,0x44,0x38,\

0x38,0x44,0x44,0x44,0x20,\

0x38,0x44,0x44,0x48,0x7F,\

0x38,0x54,0x54,0x54,0x18,\

0x8,0x7E,0x9,0x1,0x2,\

0xC,0x52,0x52,0x52,0x3E,\

0x7F,0x8,0x4,0x4,0x78,\

0x0,0x44,0x7D,0x40,0x0,\

0x0,0x20,0x40,0x44,0x3D,\

0x7F,0x10,0x28,0x44,0x0,\

0x0,0x41,0x7F,0x40,0x0,\

0x7C,0x4,0x18,0x4,0x78,\

0x7C,0x8,0x4,0x4,0x78,\

0x38,0x44,0x44,0x44,0x38,\

0x7C,0x14,0x14,0x14,0x8,\

0x8,0x14,0x14,0x18,0x7C,\

0x7C,0x8,0x4,0x4,0x8,\

0x48,0x54,0x54,0x54,0x20,\

0x4,0x3F,0x44,0x40,0x20,\

0x3C,0x40,0x40,0x20,0x7C,\

0x1C,0x20,0x40,0x20,0x1C,\

0x3C,0x40,0x30,0x40,0x3C,\

0x44,0x28,0x10,0x28,0x44,\

0xC,0x50,0x50,0x50,0x3C,\

0x44,0x64,0x54,0x4C,0x44,\

0x8,0x36,0x41,0x0,0x0,\

0x0,0x0,0x7F,0x0,0x0,\

0x0,0x0,0x41,0x36,0x8,\

0x0,0x8,0x4,0x8,0x4,\

0x0,0x0,0x0,0x0,0x0

};

const unsigned char tractor[8][128]=

{{0x00,0x00,0x08,0x40,0x00,0x80,0x00,0x08,

0x00,0x00,0x08,0x00,0x20,0x00,0x80,0x20,

0xA4,0x48,0xAC,0x08,0xAC,0x90,0x08,0x90,

0x08,0x50,0x48,0xB0,0x28,0xC0,0x58,0x60,

0xA8,0xC0,0x38,0xC0,0x58,0x50,0xA0,0x58,

0xD0,0x90,0x50,0x50,0x50,0xB0,0x40,0x50,

0xD0,0x10,0xE0,0x10,0xE0,0x10,0x60,0x40,

0xB0,0x40,0xA0,0xA0,0x40,0xA0,0x40,0xA8,

0xAA,0x42,0xE0,0xA2,0xC0,0x24,0xDC,0x68,

0x48,0xD8,0xB0,0xA8,0x54,0xE8,0xB8,0x20,

0xE8,0x58,0x70,0xE0,0x20,0xE0,0x40,0x40,

0x50,0x40,0xD0,0xE0,0x50,0xF8,0xB0,0x6C,

0xFC,0x54,0xFC,0x9C,0x74,0x5C,0xAC,0x54,

0xEC,0x54,0xFC,0xA0,0x50,0xF4,0xA0,0xD8,

0xE0,0xA0,0x40,0xC4,0x48,0xC0,0x80,0x00,

0x14,0x00,0x00,0x08,0x10,0x80,0x00,0x00},

{0x00,0x00,0x20,0x00,0x10,0x00,0x80,0x01,

0x00,0x00,0x04,0x40,0x00,0x00,0x01,0xEA,

0xBD,0xD2,0x2D,0x66,0x4A,0xDD,0x22,0x54,

0x25,0xDE,0x22,0x5D,0xF3,0x26,0xCD,0x12,

0xC2,0x3F,0xC9,0x21,0xC1,0x32,0xE5,0xDE,

0xA2,0xDD,0x93,0x7D,0xC2,0xBD,0xC3,0x3C,

0xCB,0x32,0x4D,0x5A,0x55,0x6B,0x15,0xFA,

0x83,0x7C,0x45,0x6A,0xCB,0xBA,0xA5,0x5A,

0xD5,0xDE,0xB2,0xED,0x13,0xEE,0xBB,0x55,

0xEF,0x5A,0xED,0xBB,0xD6,0xBD,0x93,0x2D,

0x42,0x1D,0x11,0xD1,0x95,0xF1,0xDA,0x75,

0xEF,0xBB,0xDE,0xB7,0xAB,0x4D,0x5B,0x64,

0x5F,0xFA,0x52,0xED,0xBB,0xEF,0xBA,0x75,

0x6F,0xBD,0xCA,0x1F,0x3B,0x46,0xBD,0x06,

0xBF,0x95,0x2F,0xDD,0x3B,0x6E,0xEB,0x5F,

0xFC,0xB9,0x74,0xE0,0x80,0x00,0x22,0x00},

{0x00,0x00,0x04,0x00,0x20,0x00,0x00,0x12,

0x80,0x00,0x00,0x01,0x40,0x00,0x00,0x9A,

0xB5,0x6F,0x90,0x6F,0x90,0xB5,0x03,0xDA,

0x82,0x39,0xC3,0x3C,0xD3,0x2E,0x51,0x82,

0x2D,0x9A,0x21,0x84,0x1B,0x72,0xAF,0x6A,

0x3A,0xE5,0xDF,0x2A,0x0A,0xAB,0x7A,0xDB,

0xE2,0xBF,0xD5,0x6E,0xD3,0xAD,0xE2,0xBE,

0x63,0xDE,0x75,0xAB,0xFA,0xC3,0x9E,0x71,

0xA6,0xFD,0x95,0x7F,0xC2,0x7D,0xE6,0x5F,

0xFA,0xB7,0xED,0xAA,0x6F,0xBA,0xCB,0xBD,

0xEB,0x5E,0xEB,0xDE,0x6B,0xDE,0x75,0xCF,

0x7A,0x5A,0x35,0x54,0x98,0x73,0xCE,0xBD,

0xF5,0x2F,0xFB,0x8E,0x53,0xCE,0xBA,0x67,

0x5A,0xFD,0xBB,0x65,0xDF,0xBE,0x75,0xAF,

0x7A,0x56,0x6B,0x7C,0xF3,0x24,0x61,0x87,

0xAA,0x1F,0xFB,0xB6,0x57,0xFE,0xC0,0x00},

{0x00,0x00,0x00,0x04,0x00,0x08,0x80,0x00,

0x80,0x88,0x90,0x40,0xC0,0x40,0xC0,0xCE,

0x39,0x56,0xE5,0xAA,0x55,0xB5,0x64,0xCC,

0xB1,0xA4,0xD5,0xA2,0xE5,0xDE,0x30,0x66,

0xCC,0x38,0xF3,0x05,0xD1,0x4B,0x20,0xC5,

0xBB,0x02,0xF5,0x9D,0x24,0x43,0xA6,0x9F,

0x20,0x47,0xDD,0x27,0xEC,0x0A,0x59,0x94,

0x0D,0xFD,0xCA,0x2A,0xDB,0xFC,0x9B,0xF6,

0x0A,0xED,0xA3,0xA6,0x5D,0xDB,0xB5,0x2E,

0xDB,0x96,0x75,0xEF,0x5D,0xFA,0xDF,0xF2,

0xAF,0x7D,0xD6,0x6F,0x9A,0x77,0xDC,0x73,

0xAD,0x4A,0xBD,0x26,0xDD,0xD3,0x7D,0xD7,

0xFD,0x03,0xEE,0xB9,0xEF,0xBA,0x5F,0xF3,

0xAF,0xA2,0x55,0xEA,0x95,0xAD,0x53,0xAD,

0x5B,0xA3,0x5F,0xF0,0x47,0x8B,0xA5,0x0C,

0x21,0x00,0xFF,0xAB,0xFE,0x2D,0x79,0x00},

{0x00,0x44,0xA0,0xB9,0x64,0xDA,0xA2,0x7F,

0xDA,0xF7,0xBD,0x57,0xFD,0xB7,0xEE,0x17,

0xE4,0x5B,0xFE,0xD5,0xAF,0x7D,0xDB,0xEE,

0xBB,0xEE,0x0D,0x0A,0x17,0x8D,0x4B,0x4C,

0xE7,0xAC,0x55,0x7E,0xD0,0xB2,0xB4,0x4D,

0xFB,0x56,0xDA,0xF2,0x95,0x70,0xAE,0xD1,

0x95,0x8A,0x02,0x0E,0x01,0x07,0x0C,0x4F,

0x3A,0xD5,0x37,0xEA,0xB7,0x6C,0xDB,0xFD,

0xAA,0x7D,0xEA,0xAF,0x55,0xC6,0xAF,0x92,

0x0F,0x4A,0x6D,0xA6,0x9F,0xAA,0x8E,0x52,

0xE3,0xA7,0xFD,0x69,0xE3,0xCE,0x3D,0xED,

0xBA,0x6F,0xDD,0x3B,0xE6,0xDD,0x77,0xDD,

0xF7,0xBA,0xD6,0x25,0xDA,0xCF,0xBB,0x5E,

0xF5,0xDF,0xBA,0x37,0xEA,0x9F,0x74,0x5A,

0xC0,0xBE,0x65,0x5D,0xAF,0x08,0x10,0xC2,

0xA0,0xFE,0xBD,0xE7,0x1D,0x8F,0x08,0x00},

{0x00,0x37,0x6E,0xFB,0xB7,0xEE,0x5B,0xFF,

0x6A,0xFF,0xAD,0xFB,0xAE,0x7D,0x98,0x77,

0xDD,0x36,0xEF,0x3A,0xF7,0xAD,0xFE,0xB5,

0x6F,0xDD,0xB9,0x4C,0xF3,0xBC,0xC7,0xBB,

0xEC,0x3B,0xFD,0x12,0xFF,0xA5,0x2B,0xDD,

0xBB,0x23,0x5E,0xE9,0xAF,0xBB,0x26,0x5D,

0xEE,0x6B,0xDE,0x78,0xC4,0x00,0x08,0x90,

0x00,0x01,0x08,0x43,0x45,0x47,0x2E,0xDB,

0x3F,0xD5,0x3F,0x75,0xAF,0x7F,0xBA,0xD7,

0xBF,0x5B,0x6F,0xFA,0xAF,0xBB,0x7F,0xA5,

0xFE,0x1F,0xF5,0x5D,0xF3,0xAC,0xDB,0x7A,

0xD7,0xDD,0xBB,0xD7,0xBE,0xEB,0xFB,0xB6,

0xED,0x5F,0xFD,0xAE,0x7A,0xED,0xDB,0xBA,

0xE3,0xE5,0x23,0xE1,0xCA,0x51,0xE5,0xB5,

0xE0,0xD2,0xB4,0x68,0xDC,0x7B,0xEE,0xBB,

0x6E,0xDB,0x31,0xE3,0x14,0xE8,0xA2,0x68},

{0x40,0x81,0x08,0x23,0x02,0x4F,0x0D,0x5B,

0x16,0x2F,0x5A,0x1F,0x55,0x0F,0x9A,0x1F,

0x15,0x4E,0x2F,0x0B,0x96,0x0F,0x2A,0x85,

0x3D,0x2E,0xFB,0x4F,0xFC,0x6B,0xFE,0xD5,

0x5F,0xF5,0xAE,0x5A,0xEE,0x39,0xE2,0x9C,

0x7D,0x93,0x6D,0x5A,0x35,0x66,0xAD,0xA0,

0x5F,0xF9,0xB7,0x4D,0x15,0x2E,0x08,0xB2,

0x05,0xA4,0x29,0x46,0x09,0x5A,0x01,0x94,

0x83,0x04,0x13,0x84,0x03,0x02,0x8A,0x02,

0x01,0x27,0x01,0x06,0x22,0x05,0x23,0x02,

0x81,0x05,0x00,0x45,0x00,0x84,0x09,0x12,

0x41,0x02,0x21,0x04,0x0B,0x42,0x9B,0x05,

0x3F,0x2D,0x1B,0x3F,0x1D,0xBB,0x16,0xBD,

0x17,0x1F,0xBB,0x2E,0x1B,0x37,0x4E,0x1B,

0x1D,0x47,0x8D,0x17,0x05,0x4F,0x0C,0xA3,

0x05,0x05,0x97,0x02,0x03,0x22,0x05,0x01},

{0x00,0x42,0x08,0x42,0x90,0x02,0x20,0x81,

0x14,0x00,0x82,0x08,0x12,0x80,0x02,0x88,

0x10,0x02,0x11,0x00,0x20,0x02,0x40,0x00,

0x05,0x08,0x13,0x07,0x2A,0x1F,0x31,0x2F,

0x7B,0x2E,0x5B,0x7E,0x3D,0x63,0x5C,0x75,

0x2E,0xB9,0x16,0x3D,0x15,0x1F,0x12,0x0F,

0x23,0x04,0x1A,0x04,0x01,0x0A,0x02,0x04,

0x0A,0x81,0x02,0x09,0x01,0x41,0x00,0x02,

0x00,0x01,0x04,0x08,0x00,0x88,0x00,0x00,

0x04,0x10,0x82,0x00,0x00,0x80,0x09,0x00,

0x90,0x00,0x02,0x08,0x90,0x00,0x00,0x12,

0x00,0x11,0x00,0x02,0x40,0x08,0x40,0x81,

0x08,0x21,0x00,0x01,0x20,0x04,0x40,0x02,

0x40,0x04,0x08,0x21,0x00,0x14,0x00,0x82,

0x08,0x00,0x20,0x02,0x08,0x00,0x22,0x00,

0x80,0x04,0x08,0x01,0x20,0x41,0x04,0x00}};

const unsigned char cfax12864c[8][128]=

{{0xF0,0xFC,0x0E,0x07,0x03,0x03,0x03,0x07,

0x0E,0x0C,0x00,0xFF,0xFF,0x83,0x83,0x83,

0x83,0x83,0xC7,0xFE,0x7C,0x00,0x03,0x0F,

0x3C,0xF0,0xC0,0xC0,0xF0,0x3C,0x0F,0x03,

0x00,0x3C,0x7E,0xE7,0xC3,0xC3,0xC3,0xC3,

0xC7,0x8E,0x0C,0x00,0x03,0x03,0x03,0xFF,

0xFF,0x03,0x03,0x03,0x00,0x00,0xE0,0xFC,

0x1F,0x1F,0xFC,0xE0,0x00,0x00,0x00,0x00,

0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0xFF,0xFF,0xC3,0xC3,

0xC3,0xC3,0xC3,0xC3,0x03,0x03,0xF0,0xFC,

0x0E,0x07,0x03,0x03,0x07,0x0E,0xFC,0xF0,

0x00,0x00,0xFF,0xFF,0x0E,0x38,0xF0,0xC0,

0x00,0x00,0xFF,0xFF,0x00,0x03,0x03,0x03,

0xFF,0xFF,0x03,0x03,0x03,0x00,0x03,0x03,

0x03,0x03,0xC3,0xE3,0x33,0x1F,0x0F,0x03},

{0x03,0x0F,0x1C,0x38,0x30,0x30,0x30,0x38,

0x1C,0x0C,0x00,0x3F,0x3F,0x01,0x01,0x03,

0x07,0x0F,0x1D,0x38,0x30,0x00,0x00,0x00,

0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x00,

0x00,0x0C,0x1C,0x38,0x30,0x30,0x30,0x30,

0x39,0x1F,0x0F,0x00,0x00,0x00,0x00,0x3F,

0x3F,0x00,0x00,0x00,0x38,0x3F,0x07,0x06,

0x06,0x06,0x06,0x07,0x3F,0x38,0x00,0x00,

0x3F,0x3F,0x30,0x30,0x30,0x30,0x30,0x30,

0x30,0x30,0x00,0x00,0x3F,0x3F,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0F,

0x1C,0x38,0x30,0x30,0x38,0x1C,0x0F,0x03,

0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x03,

0x07,0x1C,0x3F,0x3F,0x00,0x00,0x00,0x00,

0x3F,0x3F,0x00,0x00,0x00,0x00,0x30,0x3C,

0x3E,0x33,0x31,0x30,0x30,0x30,0x30,0x30},

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x1C,

0x0C,0x0C,0x1C,0x38,0x70,0x20,0x00,0x00,

0x80,0xC0,0xE0,0x70,0x38,0x1C,0x0C,0x0C,

0x1C,0x38,0x70,0xE0,0xC0,0x80,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x7C,0xFE,0x83,0x01,0x01,0xC7,0xC6,

0x00,0x01,0xFF,0xFF,0x11,0x11,0x3B,0x07,

0x00,0xFC,0xFE,0x23,0x23,0xFE,0xFC,0x00,

0x00,0xC7,0xEF,0x38,0x38,0x38,0xEF,0xC7,

0x00,0x04,0x04,0xFE,0xFF,0x00,0x00,0x00,

0x00,0x86,0xC7,0x61,0x31,0x9F,0x8E,0x00,

0x00,0xEE,0xFF,0x19,0x31,0xFF,0xEE,0x00,

0x00,0xFC,0xFE,0x13,0x11,0xF1,0xE0,0x00,

0x00,0x30,0x38,0x2C,0x26,0xFF,0xFF,0x20,

0x00,0x7C,0xFE,0x83,0x01,0x01,0xC7,0xC6},

{0x80,0x80,0x80,0x80,0x80,0x80,0x98,0x9C,

0x9E,0x9F,0x9F,0x9F,0x9F,0x80,0x80,0x80,

0x80,0x00,0x00,0x00,0xF8,0xFC,0xFE,0xFF,

0xFF,0xFF,0xFF,0x00,0x00,0x80,0x80,0x80,

0x80,0x80,0x80,0x9F,0x9F,0x9F,0x9F,0x9E,

0x9C,0x98,0x80,0x80,0x80,0x80,0x80,0x80,

0x00,0x80,0x00,0x01,0x81,0x01,0x01,0x80,

0x00,0x01,0x81,0x81,0x81,0x80,0x00,0x00,

0x80,0x01,0x01,0x80,0x00,0x01,0x81,0x00,

0x00,0x81,0x01,0x00,0x80,0x00,0x01,0x81,

0x00,0x01,0x81,0x01,0x01,0x81,0x01,0x00,

0x80,0x01,0x01,0x81,0xC1,0xE1,0xF1,0x38,

0x1C,0x8E,0x07,0x07,0x8F,0x1D,0x38,0xF0,

0xE0,0x80,0x81,0x01,0x01,0x81,0x00,0x00,

0x80,0x00,0x00,0x80,0x01,0x01,0x81,0x01,

0x00,0x80,0x00,0x01,0x81,0x01,0x01,0x80},

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0x00,0x00,0x99,0x99,0x99,

0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,

0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,

0x00,0xC0,0xE0,0xB0,0xB8,0x9C,0x8E,0x86,

0x83,0x83,0x81,0x81,0x81,0x83,0x83,0x87,

0x8E,0x9C,0xB8,0xF0,0xE0,0x80,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

0xC0,0xF0,0xBC,0x9F,0x87,0x81,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

0x83,0x8F,0xBE,0xF8,0xE0,0x80,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80},

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0x00,0x00,0x99,0x99,0x99,

0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,

0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,

0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0x01,0x03,0x0F,0x1D,

0x79,0xF1,0xC1,0x81,0x01,0x01,0x01,0x01,

0x01,0x01,0x81,0xC1,0xE1,0x79,0x1D,0x0F,

0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0x07,0x1F,0x7D,0xF1,

0xC1,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0xC1,0xF1,0x7F,0x1F},

{0x01,0x01,0x01,0x01,0x01,0x01,0x19,0x39,

0x79,0xF9,0xF9,0xF9,0xF9,0x01,0x01,0x01,

0x01,0x00,0x00,0x00,0x1F,0x3F,0x7F,0xFF,

0xFF,0xFF,0xFF,0x00,0x00,0x01,0x01,0x01,

0x01,0x01,0x01,0xF9,0xF9,0xF9,0xF9,0x79,

0x39,0x19,0x01,0x01,0x01,0x01,0x01,0x01,

0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,

0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,

0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,

0x00,0x01,0x01,0x01,0x03,0x07,0x06,0x07,

0x06,0x07,0x03,0x01,0x00,0x01,0x00,0x00,

0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,

0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,

0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x03,

0x07,0x1E,0x38,0xF1,0xC0,0x80,0x81,0x80,

0xC0,0xF1,0x78,0x1F,0x07,0x01,0x00,0x01},

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x01,0x03,0x07,0x0E,0x1C,0x38,

0x30,0x30,0x38,0x1C,0x0E,0x04,0x00,0x00,

0x01,0x03,0x07,0x0E,0x1C,0x38,0x30,0x30,

0x38,0x1C,0x0E,0x07,0x03,0x01,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x4C,0x92,0x92,0x92,0x64,0x00,0xFE,

0x04,0x08,0x04,0xFE,0x00,0xFC,0x22,0x22,

0x22,0xFC,0x00,0xFE,0x80,0x80,0x80,0x80,

0x00,0xFE,0x80,0x80,0x80,0x80,0x00,0x00,

0x00,0x00,0x00,0x78,0x94,0x92,0x92,0x60,

0x00,0xD8,0x20,0x20,0xD8,0x00,0x00,0x6C,

0x92,0x92,0x92,0x6C,0x00,0x00,0x00,0x00,

0x00,0x02,0x02,0xFE,0x02,0x02,0x00,0xFE,

0x92,0x92,0x92,0x82,0x01,0xC7,0x29,0x11,

0x29,0xC6,0x00,0x02,0x02,0xFE,0x02,0x02}};

const unsigned char cfax12864a[8][128]=

{{0xF0,0xFC,0x0E,0x07,0x03,0x03,0x03,0x07,

0x0E,0x0C,0x00,0xFF,0xFF,0x83,0x83,0x83,

0x83,0x83,0xC7,0xFE,0x7C,0x00,0x03,0x0F,

0x3C,0xF0,0xC0,0xC0,0xF0,0x3C,0x0F,0x03,

0x00,0x3C,0x7E,0xE7,0xC3,0xC3,0xC3,0xC3,

0xC7,0x8E,0x0C,0x00,0x03,0x03,0x03,0xFF,

0xFF,0x03,0x03,0x03,0x00,0x00,0xE0,0xFC,

0x1F,0x1F,0xFC,0xE0,0x00,0x00,0x00,0x00,

0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0xFF,0xFF,0xC3,0xC3,

0xC3,0xC3,0xC3,0xC3,0x03,0x03,0xF0,0xFC,

0x0E,0x07,0x03,0x03,0x07,0x0E,0xFC,0xF0,

0x00,0x00,0xFF,0xFF,0x0E,0x38,0xF0,0xC0,

0x00,0x00,0xFF,0xFF,0x00,0x03,0x03,0x03,

0xFF,0xFF,0x03,0x03,0x03,0x00,0x03,0x03,

0x03,0x03,0xC3,0xE3,0x33,0x1F,0x0F,0x03},

{0x03,0x0F,0x1C,0x38,0x30,0x30,0x30,0x38,

0x1C,0x0C,0x00,0x3F,0x3F,0x01,0x01,0x03,

0x07,0x0F,0x1D,0x38,0x30,0x00,0x00,0x00,

0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x00,

0x00,0x0C,0x1C,0x38,0x30,0x30,0x30,0x30,

0x39,0x1F,0x0F,0x00,0x00,0x00,0x00,0x3F,

0x3F,0x00,0x00,0x00,0x38,0x3F,0x07,0x06,

0x06,0x06,0x06,0x07,0x3F,0x38,0x00,0x00,

0x3F,0x3F,0x30,0x30,0x30,0x30,0x30,0x30,

0x30,0x30,0x00,0x00,0x3F,0x3F,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0F,

0x1C,0x38,0x30,0x30,0x38,0x1C,0x0F,0x03,

0x00,0x00,0x3F,0x3F,0x00,0x00,0x00,0x03,

0x07,0x1C,0x3F,0x3F,0x00,0x00,0x00,0x00,

0x3F,0x3F,0x00,0x00,0x00,0x00,0x30,0x3C,

0x3E,0x33,0x31,0x30,0x30,0x30,0x30,0x30},

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x80,0xC0,0xE0,0x70,0x38,0x1C,

0x0C,0x0C,0x1C,0x38,0x70,0x20,0x00,0x00,

0x80,0xC0,0xE0,0x70,0x38,0x1C,0x0C,0x0C,

0x1C,0x38,0x70,0xE0,0xC0,0x80,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x7C,0xFE,0x83,0x01,0x01,0xC7,0xC6,

0x00,0x01,0xFF,0xFF,0x11,0x11,0x3B,0x07,

0x00,0xFC,0xFE,0x23,0x23,0xFE,0xFC,0x00,

0x00,0xC7,0xEF,0x38,0x38,0x38,0xEF,0xC7,

0x00,0x04,0x04,0xFE,0xFF,0x00,0x00,0x00,

0x00,0x86,0xC7,0x61,0x31,0x9F,0x8E,0x00,

0x00,0xEE,0xFF,0x19,0x31,0xFF,0xEE,0x00,

0x00,0xFC,0xFE,0x13,0x11,0xF1,0xE0,0x00,

0x00,0x30,0x38,0x2C,0x26,0xFF,0xFF,0x20,

0x00,0x00,0xFC,0xFE,0x23,0x23,0xFE,0xFC},

{0x80,0x80,0x80,0x80,0x80,0x80,0x98,0x9C,

0x9E,0x9F,0x9F,0x9F,0x9F,0x80,0x80,0x80,

0x80,0x00,0x00,0x00,0xF8,0xFC,0xFE,0xFF,

0xFF,0xFF,0xFF,0x00,0x00,0x80,0x80,0x80,

0x80,0x80,0x80,0x9F,0x9F,0x9F,0x9F,0x9E,

0x9C,0x98,0x80,0x80,0x80,0x80,0x80,0x80,

0x00,0x80,0x00,0x01,0x81,0x01,0x01,0x80,

0x00,0x01,0x81,0x81,0x81,0x80,0x00,0x00,

0x80,0x01,0x01,0x80,0x00,0x01,0x81,0x00,

0x00,0x81,0x01,0x00,0x80,0x00,0x01,0x81,

0x00,0x01,0x81,0x01,0x01,0x81,0x01,0x00,

0x80,0x01,0x01,0x81,0xC1,0xE1,0xF1,0x38,

0x1C,0x8E,0x07,0x07,0x8F,0x1D,0x38,0xF0,

0xE0,0x80,0x81,0x01,0x01,0x81,0x00,0x00,

0x80,0x00,0x00,0x80,0x01,0x01,0x81,0x01,

0x00,0x80,0x01,0x01,0x80,0x00,0x01,0x81},

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0x00,0x00,0x99,0x99,0x99,

0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,

0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,

0x00,0xC0,0xE0,0xB0,0xB8,0x9C,0x8E,0x86,

0x83,0x83,0x81,0x81,0x81,0x83,0x83,0x87,

0x8E,0x9C,0xB8,0xF0,0xE0,0x80,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

0xC0,0xF0,0xBC,0x9F,0x87,0x81,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

0x83,0x8F,0xBE,0xF8,0xE0,0x80,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,

0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80},

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0x00,0x00,0x99,0x99,0x99,

0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,

0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,

0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0x01,0x03,0x0F,0x1D,

0x79,0xF1,0xC1,0x81,0x01,0x01,0x01,0x01,

0x01,0x01,0x81,0xC1,0xE1,0x79,0x1D,0x0F,

0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0x07,0x1F,0x7D,0xF1,

0xC1,0x01,0x01,0x01,0x01,0x01,0x01,0x01,

0x01,0x01,0x01,0x01,0xC1,0xF1,0x7F,0x1F},

{0x01,0x01,0x01,0x01,0x01,0x01,0x19,0x39,

0x79,0xF9,0xF9,0xF9,0xF9,0x01,0x01,0x01,

0x01,0x00,0x00,0x00,0x1F,0x3F,0x7F,0xFF,

0xFF,0xFF,0xFF,0x00,0x00,0x01,0x01,0x01,

0x01,0x01,0x01,0xF9,0xF9,0xF9,0xF9,0x79,

0x39,0x19,0x01,0x01,0x01,0x01,0x01,0x01,

0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,

0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,

0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,

0x00,0x01,0x01,0x01,0x03,0x07,0x06,0x07,

0x06,0x07,0x03,0x01,0x00,0x01,0x00,0x00,

0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,

0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,

0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x03,

0x07,0x1E,0x38,0xF1,0xC0,0x80,0x81,0x80,

0xC0,0xF1,0x78,0x1F,0x07,0x01,0x00,0x01},

{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x01,0x03,0x07,0x0E,0x1C,0x38,

0x30,0x30,0x38,0x1C,0x0E,0x04,0x00,0x00,

0x01,0x03,0x07,0x0E,0x1C,0x38,0x30,0x30,

0x38,0x1C,0x0E,0x07,0x03,0x01,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x4C,0x92,0x92,0x92,0x64,0x00,0xFE,

0x04,0x08,0x04,0xFE,0x00,0xFC,0x22,0x22,

0x22,0xFC,0x00,0xFE,0x80,0x80,0x80,0x80,

0x00,0xFE,0x80,0x80,0x80,0x80,0x00,0x00,

0x00,0x00,0x00,0x78,0x94,0x92,0x92,0x60,

0x00,0xD8,0x20,0x20,0xD8,0x00,0x00,0x6C,

0x92,0x92,0x92,0x6C,0x00,0x00,0x00,0x00,

0x00,0x02,0x02,0xFE,0x02,0x02,0x00,0xFE,

0x92,0x92,0x92,0x82,0x01,0xC7,0x29,0x11,

0x29,0xC6,0x00,0x02,0x02,0xFE,0x02,0x02}};

/////////////////////////////////////////////////////////////////////////////

/**********************************************************

MAIN

**********************************************************/

int main (void) {

Initialize();

LCD_init();

BL_ON(0);

int

row;

for(row=0;row<=7;row++)

{

//Page Address

LCD_command(0xB0|row);

//High Column

LCD_command(0x10);

//Low Column For some reason the Left-most column of the

//CFAX12864 is at 4. Hmmm.

LCD_command(0x00);

int

col;

for(col=0;col<=127;col++)

{

LCD_out(cfax12864a[row][col]);

RD(1);

RS(1);

RW(0);

RW(1);

}

}

}

// send command to the LCD

void LCD_command(unsigned char command)

{

RS(0);

RD(1);

LCD_out(command);

//PORTD = comm_byte;

//TRISD = 0b.0000.0000; //Turn PORTD to Output

RW(0);

RW(1);

RD(0);

}

// initialize LCD

void LCD_init()

{

RSTB(0);

delay();

RSTB(1);

delay();

LCD_command(LCD_ON); //On LCD

//Best boot 5-1-05

LCD_command(0xA3); //LCD Bias (A2 A3) - First Choice

LCD_command(0x2F); //Turn on internal power control

LCD_command(0x26); //Pseudo-Contrast 7 = dark 6 = OK - First Choice

LCD_command(0x81); //Set contrast

LCD_command(54);

LCD_command(0xC8); //Flip screen on the horizontal to match with the vertical software invertion

LCD_clear_screen();

}

void LCD_clear_screen(void){

unsigned char i, j;

for( i = 0 ; i < 9 ; i++ )

for( j = 0 ; j < 133 ; j++ )

//Data, Page num, Col

LCD_write_data(0x00, i, j);

}

//Writes byte to selected page

void LCD_write_data(unsigned char data, unsigned char page, unsigned char column)

{

// make sure column and page are within bounds

page %= 9;

column %= 128;

// set column MSB

LCD_command(0x10 | ((/*127 - */column) >> 4));

// set column LSB

LCD_command(0x0F & (/*127 - */column));

// set page

LCD_command(0xB0 |(0x0F & page));

//Data write

LCD_out(data);

RD(1);

RS(1);

RW(0);

RW(1);

RD(0); //Must have this! Or else the screen will shimmer black

}

// these functions set / clear pins for LCD control lines. they accecpt a 0 or 1

void RD(char stat)

{

IODIR0 |= 0x00040000; // RD is P0.18

if (stat)

IOSET0 |= 0x00040000;

else

IOCLR0 |= 0x00040000;

}

void RW(char stat)

{

IODIR0 |= 0x00020000; // RW is P0.17

if (stat)

IOSET0 |= 0x00020000;

else

IOCLR0 |= 0x00020000;

}

void RS(char stat)

{

IODIR0 |= 0x40000000; // RS is P0.30

if (stat)

IOSET0 |= 0x40000000;

else

IOCLR0 |= 0x40000000;

}

void RSTB(char stat)

{

IODIR0 |= 0x00000080; // RSTB is P0.7

if (stat)

IOSET0 |= 0x00000080;

else

IOCLR0 |= 0x00000080;

}

void BL_ON(char stat)

// BLON is P0.31

{

IODIR0 |= 0x80000000;

if (stat)

IOSET0 |= 0x80000000;

else

IOCLR0 |= 0x80000000;

}

void TS4(unsigned char stat)

{

// TS4 is P0.3

if (stat == 1)

{

IODIR0 |= 0x00000008;

IOSET0 |= 0x00000008;

}

else if (stat == 0)

{

IODIR0 |= 0x00000008;

IOCLR0 |= 0x00000008;

}

else

IODIR0 &= ~0x00000008;

}

void TS3(unsigned char stat)

{

// TS3 is P0.4

if (stat == 1)

{

IODIR0 |= 0x00000010;

IOSET0 |= 0x00000010;

}

else if (stat == 0)

{

IODIR0 |= 0x00000010;

IOCLR0 |= 0x00000010;

}

else

IODIR0 &= ~0x00000010;

}

void TS2(unsigned char stat)

{

// TS2 is P0.5

if (stat == 1)

{

IODIR0 |= 0x00000020;

IOSET0 |= 0x00000020;

}

else if (stat == 0)

{

IODIR0 |= 0x00000020;

IOCLR0 |= 0x00000020;

}

else

IODIR0 &= ~0x00000020;

}

void TS1(unsigned char stat)

{

// TS1 is P0.6

if (stat == 1)

{

IODIR0 |= 0x00000040;

IOSET0 |= 0x00000040;

}

else if (stat == 0)

{

IODIR0 |= 0x00000040;

IOCLR0 |= 0x00000040;

}

else

IODIR0 &= ~0x00000040;

}

int adc_TS2(void)

{

static int val;

AD0CR = 0;

AD0DR = 0;

ADGSR = 0;

PINSEL0 = 0x00000C00;

AD0CR = 0x00200680;

AD0CR |= 0x01000000;

//ADGSR = 0x01000000;

do

{

val = AD0DR; // Read A/D Data Register

}

while ((val & 0x80000000) == 0); //Wait for the conversion to complete

val = ((val >> 6) & 0x03FF); //Extract the A/D result

//while(!(AD0DR & 0x80000000));

return val;

}

int adc_TS3(void)

{

static int val2;

AD0CR = 0;

AD0DR = 0;

ADGSR = 0;

PINSEL0 = 0x00000300;

AD0CR = 0x00200640;

AD0CR |= 0x01000000;

//ADGSR = 0x01000000;

do

{

val2 = AD0DR; // Read A/D Data Register

}

while ((val2 & 0x80000000) == 0); //Wait for the conversion to complete

val2 = ((val2 >> 6) & 0x03FF); //Extract the A/D result

//while(!(AD0DR & 0x80000000));

return val2;

}

// send to the LCD

void LCD_out(unsigned char cmd)

{

IODIR0 |= 0x2CF80000; // set lcd data pins to output

IOCLR0 |= 0x2CF80000; // clear all pins

IOSET0 |= get_LCD_port(cmd); // set port

}

/* the lcd connects to the LPC like so:

  • D0 → P0.19

  • D1 → P0.20

  • D2 → P0.21

  • D3 → P0.22

  • D4 → P0.23

  • D5 → P0.26

  • D6 → P0.27

  • D7 → P0.29

  • this function takes data byte and returns an int that can be

  • assigned to these pins

*/

unsigned int get_LCD_port(unsigned char data)

{

return ((data & 0x01) << 19) | ((data & 0x02) << 19) | ((data & 0x04) << 19) |

((data & 0x08) << 19) | ((data & 0x10) << 19) |

((data & 0x20) << 21) | ((data & 0x40) << 21) | ((data & 0x80) << 22);

}

void delay(void){

volatile unsigned int count = 0;

for (count = 0; count < 4000000; count++){

asm volatile (“nop”);

}

}

/**********************************************************

Initialize

**********************************************************/

#define PLOCK 0x400

void Initialize(void) {

// Setting the Phased Lock Loop (PLL)

// ----------------------------------

//

// Olimex LPC-P2106 has a 14.7456 mhz crystal

//

// We’d like the LPC2106 to run at 53.2368 mhz (has to be an even multiple of crystal)

//

// According to the Philips LPC2106 manual: M = cclk / Fosc where: M = PLL multiplier (bits 0-4 of PLLCFG)

// cclk = 53236800 hz

// Fosc = 14745600 hz

//

// Solving: M = 53236800 / 14745600 = 3.6103515625

// M = 4 (round up)

//

// Note: M - 1 must be entered into bits 0-4 of PLLCFG (assign 3 to these bits)

//

//

// The Current Controlled Oscilator (CCO) must operate in the range 156 mhz to 320 mhz

//

// According to the Philips LPC2106 manual: Fcco = cclk * 2 * P where: Fcco = CCO frequency

// cclk = 53236800 hz

// P = PLL divisor (bits 5-6 of PLLCFG)

//

// Solving: Fcco = 53236800 * 2 * P

// P = 2 (trial value)

// Fcco = 53236800 * 2 * 2

// Fcc0 = 212947200 hz (good choice for P since it’s within the 156 mhz to 320 mhz range

//

// From Table 19 (page 48) of Philips LPC2106 manual P = 2, PLLCFG bits 5-6 = 1 (assign 1 to these bits)

//

// Finally: PLLCFG = 0 01 00011 = 0x23

//

// Final note: to load PLLCFG register, we must use the 0xAA followed 0x55 write sequence to the PLLFEED register

// this is done in the short function feed() below

//

// Setting Multiplier and Divider values

PLLCFG=0x23;

feed();

// Enabling the PLL */

PLLCON=0x1;

feed();

// Wait for the PLL to lock to set frequency

while(!(PLLSTAT & PLOCK)) ;

// Connect the PLL as the clock source

PLLCON=0x3;

feed();

// Enabling MAM and setting number of clocks used for Flash memory fetch (4 cclks in this case)

MAMCR=0x2;

MAMTIM=0x4;

// Setting peripheral Clock (pclk) to System Clock (cclk)

VPBDIV=0x1;

}

void feed(void)

{

PLLFEED=0xAA;

PLLFEED=0x55;

}

/* Stubs for various interrupts (may be replaced later) */

/* ---------------------------------------------------- */

void IRQ_Routine (void) {

while (1) ;

}

void FIQ_Routine (void) {

while (1) ;

}

void SWI_Routine (void) {

while (1) ;

}

void UNDEF_Routine (void) {

while (1) ;

}

Nice images of the screen. good job!

The BL_EN pin is for controlling the backlight circuit. A high value will turn the backlight on.

Owen

as you can see from the code i have enabled pin 31(on which is the BL_EN) with the command :

BL_ON(0);

in the begining of the code

and have as the function:

void BL_ON(char stat)

// BLON is P0.31

{

IODIR0 |= 0x80000000;

if (stat)

IOSET0 |= 0x80000000;

else

IOCLR0 |= 0x80000000;

}

for some reason the backlight doesn’t turn on.

Why is that?

am i doing something wrong here?

Your code looks good. Did you check the pin actually goes high with a meter? You can also try measuring the voltage across the two backlight connections. It should be around 60 VAC.

Owen

the Voltage on the Backlight pins is : 19mv (nothing) Also when i reset the LPC the pin stays at 2.3 v untill the LPC initializes and then as soon as the screen shows an image the pin goes to nothing.

PS: on the image i don’t know if you can see it but the GND pin to the far left of the LCD is not connected to the LPC board.

The image shows fine without it.

Could that be the problem?