پروژه راه اندازی LCD موبایل 3310
این نوع LCD دارای 8 پایه است. ترتیب پایه ها به صورت زیر است:
1- VDD (3.3Volt)
2- SCK (Serial Clk)
3- SDIN (Serial Data)
4- DC (Select Data or Command
C=1 select data , DC=0 select command)
5- CS (Chip Select)
6- GND
7- V lcd
8- RST
خوشبختانه به علت یکسان بودن ولتاژ LCD موبایل 3310 و میکروکنترولر، پایه های LCD به صورت مستقیم به میکروکنترولر متصل می شود . اگر به پشت LCD نگاه کنید یک زایده نزدیک پایه یک مشاهده خوا هید کرد .
نقشه زیر برای آزمایش کردن LCD موبایل 3310 ببندید .
ببخشید نتونستم نقشه را کپی کنم ولی همان طوری که از برنامه معلوم است LCD را به میکروی LPC2368 و به پورت صفر وصل است بقیه پایه ها را نیز از متن برنامه بخوانید . پایه VLCD را با یک خازن 10نانو زمین کنید
پروژه جدید با نام LCD_3310 در مسیر PROJECTSبسازید .
فایلی با نام config.h بسازید و برنامه زیر را در آن بنویسید
/**************************
* File: config.h
**************************/
#ifndef _CONFIG_H
#define _CONFIG_H
#include "iolpc2368.h"
#define CCLK 4000000 //XTAL frequency in Hz (PLL is disable)
#define PCLK (CCLK/4) //asummed VPB divider is 4
#define TRUE 1
#define FALSE 0
#endif
/**************************
* end of file
**************************/
فایلی با نام config.c بسازید و برنامه زیر را در آن بنویسید
/**************************
* File: config.c
**************************/
#include "config.h"
/**************************
* end of file
**************************/
فایلی با نام nokia.h بسازید و برنامه زیر را در آن بنویسید
/**************************
* File: nokia.h
**************************/
#ifndef _NOKIA_H
#define _NOKIA_H
#include "config.h"
#define NOKIA_DIR IO0DIR
#define NOKIA_SET IO0SET
#define NOKIA_CLR IO0CLR
#define NOKIA_PIN IO0PIN
#define SCK (1<<22)
#define SDA (1<<21)
#define DC (1<<20)
#define CS (1<<19)
#define RST (1<<18)
#define NOKIA_MASK (0x00780800)
void nokia_init(void);
void nokia_clear(void);
void nokia_gotoxy(unsigned char , unsigned char);
void nokia_putsf(unsigned char *);
void nokia_command(unsigned char);
void nokia_char(unsigned char);
void nokia_puts(long);
void nokia_byte(unsigned char);
void nokia_display_pitcher(unsigned char *);
#endif
/**************************
* end of file
**************************/
فایلی با نام nokia.c بسازید و برنامه زیر را در آن بنویسید
/**************************
* File: lcd.c
**************************/
#include "config.h"
#include "nokia.h"
static void nokia_dorc(unsigned char);
static void nokia_delay(unsigned short);
uint8_t const font[][5]={
{0x00,0x00,0x00,0x00,0x00}, // SPACE
{0x00,0x00,0x2F,0x00,0x00}, // !
{0x00,0x07,0x00,0x07,0x00}, // "
{0x14,0x7F,0x14,0x7F,0x14}, // #
{0x2C,0x2A,0x7F,0x2A,0x12}, // $
{0x23,0x13,0x08,0x64,0x62}, // %
{0x36,0x49,0x55,0x22,0x50}, // &
{0x00,0x05,0x03,0x00,0x00}, // '
{0x00,0x1C,0x22,0x41,0x00}, // (
{0x00,0x41,0x22,0x1C,0x00}, // )
{0x14,0x08,0x3E,0x08,0x14}, // *
{0x08,0x08,0x3E,0x08,0x08}, // +
{0x00,0x50,0x30,0x00,0x00}, // ,
{0x08,0x08,0x08,0x08,0x08}, // -
{0x00,0x18,0x18,0x00,0x00}, // .
{0x20,0x10,0x08,0x04,0x02}, // /
{0x3E,0x51,0x49,0x45,0x3E}, // 0
{0x00,0x42,0x7F,0x40,0x00}, // 1
{0x42,0x61,0x51,0x49,0x46}, // 2
{0x21,0x41,0x45,0x4B,0x31}, // 3
{0x18,0x14,0x12,0x7F,0x10}, // 4
{0x27,0x45,0x45,0x45,0x39}, // 5
{0x3C,0x4A,0x49,0x49,0x30}, // 6
{0x01,0x71,0x09,0x05,0x03}, // 7
{0x36,0x49,0x49,0x49,0x36}, // 8
{0x06,0x49,0x49,0x29,0x1e}, // 9
{0x00,0x36,0x36,0x00,0x00}, // :
{0x00,0x56,0x36,0x00,0x00}, // ;
{0x08,0x14,0x22,0x41,0x00}, // <
{0x28,0x28,0x28,0x28,0x28}, // =
{0x00,0x41,0x22,0x14,0x08}, // >
{0x02,0x01,0x51,0x09,0x06}, // ?
{0x32,0x49,0x79,0x41,0x3E}, // @
{0x7E,0x11,0x11,0x11,0x7E}, // A
{0x7F,0x49,0x49,0x49,0x36}, // B
{0x3E,0x41,0x41,0x41,0x22}, // C
{0x7F,0x41,0x41,0x22,0x1C}, // D
{0x7F,0x49,0x49,0x49,0x41}, // E
{0x7F,0x09,0x09,0x09,0x01}, // F
{0x3E,0x41,0x49,0x59,0x7A}, // G
{0x7F,0x08,0x08,0x08,0x7F}, // H
{0x00,0x41,0x7F,0x41,0x00}, // I
{0x20,0x40,0x41,0x3F,0x01}, // J
{0x7F,0x08,0x14,0x22,0x41}, // K
{0x7F,0x40,0x40,0x40,0x40}, // L
{0x7F,0x02,0x0C,0x02,0x7F}, // M
{0x7F,0x04,0x08,0x10,0x7F}, // N
{0x3E,0x41,0x41,0x41,0x3E}, // O
{0x7F,0x09,0x09,0x09,0x06}, // P
{0x3E,0x41,0x51,0x21,0x5E}, // Q
{0x7F,0x09,0x19,0x29,0x46}, // R
{0x46,0x49,0x49,0x49,0x31}, // S
{0x01,0x01,0x7F,0x01,0x01}, // T
{0x3F,0x40,0x40,0x40,0x3F}, // U
{0x1F,0x20,0x40,0x20,0x1F}, // V
{0x3F,0x40,0x38,0x40,0x3F}, // W
{0x63,0x14,0x08,0x14,0x63}, // X
{0x07,0x08,0x70,0x08,0x07}, // Y
{0x61,0x51,0x49,0x45,0x43}, // Z
{0x00,0x7F,0x41,0x41,0x00}, // [
{0x15,0x16,0x7C,0x16,0x15}, // ??
{0x00,0x41,0x14,0x7F,0x00}, // ]
{0x04,0x02,0x01,0x02,0x04}, // ^
{0x40,0x40,0x40,0x40,0x40}, // _
{0x02,0x04,0x08,0x10,0x20}, /* \ */
{0x20,0x54,0x54,0x54,0x78}, // a
{0x7F,0x50,0x48,0x48,0x30}, // b
{0x38,0x44,0x44,0x44,0x20}, // c
{0x30,0x48,0x48,0x50,0x7F}, // d
{0x38,0x54,0x54,0x54,0x18}, // e
{0x08,0x7E,0x09,0x01,0x02}, // f
{0x0C,0x52,0x52,0x52,0x3E}, // g
{0x7F,0x08,0x04,0x04,0x78}, // h
{0x00,0x44,0x7D,0x40,0x00}, // i
{0x20,0x40,0X44,0x3D,0x00}, // j
{0x7F,0x10,0x28,0x44,0x00}, // k
{0x00,0x41,0x7F,0x40,0x00}, // l
{0x7C,0x04,0x18,0x04,0x78}, // m
{0x7C,0x08,0x04,0x04,0x78}, // n
{0x38,0x44,0x44,0x44,0x38}, // o
{0x7C,0x14,0x14,0x14,0x08}, // p
{0x08,0x14,0x14,0x18,0x7C}, // q
{0x7C,0x08,0x04,0x04,0x08}, // r
{0x48,0x54,0x54,0x54,0x20}, // s
{0x04,0x3F,0x44,0x40,0x20}, // t
{0x3C,0x40,0x40,0x20,0x7C}, // u
{0x1C,0x20,0x40,0x20,0x1C}, // v
{0x3C,0x40,0x30,0x40,0x3C}, // w
{0x44,0x28,0x10,0x28,0x44}, // x
{0x0C,0x50,0x50,0x50,0x3C}, // y
{0x44,0x64,0x54,0x4C,0x44}, // z
{0x00,0x08,0x36,0x41,0x00}, // {
{0x00,0x00,0x7F,0x00,0x00}, // |
{0x00,0x41,0x36,0x08,0x00}, // }
{0x08,0x08,0x2A,0x1C,0x08}, // ->
{0x08,0x1C,0x2A,0x08,0x08} // <-
};
/**************************
* nokia command()
**************************/
void nokia_command(unsigned char data)
{
NOKIA_CLR |= (DC|CS);
nokia_dorc(data);
NOKIA_SET |= CS;
}
/**************************
* nokia byte()
**************************/
void nokia_byte(unsigned char data)
{
NOKIA_SET |= DC;
NOKIA_CLR |= CS;
nokia_dorc(data);
NOKIA_SET |= CS;
}
/**************************
* nokia dorc()
**************************/
void nokia_dorc(unsigned char data)
{
unsigned char i;
for (i=0;i<8;i++)
{
NOKIA_CLR |= SDA;
if( data & ( 1 << (7-i) ) ) NOKIA_SET |= SDA;
NOKIA_CLR |= SCK;
NOKIA_SET |= SCK;
}
}
/**************************
* nokia data()
**************************/
void nokia_char(unsigned char data)
{
unsigned char i;
for (i=0;i<5;i++)
nokia_byte(font[data-32][i]);
nokia_byte(0);
}
/**************************
* nokia Init()
**************************/
void nokia_init(void)
{
NOKIA_DIR|=NOKIA_MASK; // set lcd data lines to output
NOKIA_SET |= NOKIA_MASK;
nokia_delay(200);
NOKIA_CLR |= RST;
nokia_delay(200);
NOKIA_SET |= RST;
nokia_command(0x21);
nokia_command(0xc2);
nokia_command(0x13);
nokia_command(0x20);
nokia_command(0x09);
nokia_clear();
nokia_delay(200);
nokia_command(0x08);
nokia_delay(200);
nokia_command(0x0c);
nokia_clear();
}
/**************************
* nokia_putsf()
**************************/
void nokia_putsf(unsigned char *p)
{
while(*p !='\0'
nokia_char(*(p++));
}
/**************************
* nokia_display pitcher()
**************************/
void nokia_display_pitcher(unsigned char *p)
{
unsigned char i,j;
nokia_command(0x22);
nokia_gotoxy(0,0);
for(i=0 ; i<6 ;i++)
{
for(j=0 ; j<84 ; j++)
nokia_byte(*(p++));
}
nokia_command(0x20);
}
/**************************
* nokia gotoxy()
**************************/
void nokia_gotoxy(unsigned char x, unsigned char y)
{
y &= 7;
nokia_command((y|=0x40));
nokia_command((x|=0x80));
}
/**************************
* nokia delay()
**************************/
void nokia_delay(unsigned short time)
{
unsigned short i,j;
for(i=0;i<time;i++)
for(j=0;j<1000;j++);
}
/**************************
* nokia clear()
**************************/
void nokia_clear(void)
{
unsigned char i,j;
nokia_gotoxy(0,0);
for(i=0 ; i < 6 ; i++)
{
for(j=0 ; j < 84 ; j++)
nokia_byte(0);
}
}
/**************************
* nokia_puts()
**************************/
void nokia_puts(long Num)
{
unsigned char temp[16],i,j,k;
if (Num<0)
{
Num=-Num;
nokia_char('-'
;
}
for(i=0;i<16;i++)
temp[i]=0;
j=0;
do
{
temp[j++] = '0' + Num % 10;
Num=Num/10;
} while (Num > 0);
for(i=0;i<=((j-1)/2);i++)
{
k=temp[i];
temp[i]=temp[j-i-1];
temp[j-i-1]=k;
}
temp[j]='\0';
nokia_putsf(temp);
}
/**************************
* end of file
**************************/
فایلی با نام main.c بسازید و برنامه زیر را در آن بنویسید
/**************************
* main.c
**************************/
#include "config.h"
#include "nokia.h"
unsigned char pitcher1[]=
{
0, 0, 192, 15, 0, 0,
0, 0, 112, 28, 128, 3,
0, 0, 0, 24, 192, 7,
0, 0, 0, 24, 128, 3,
0, 0, 96, 24, 0, 0,
0, 0, 248, 24, 28, 0,
0, 0, 204, 24, 126, 0,
0, 0, 204, 29, 115, 0,
0, 0, 204, 13, 254, 3,
0, 0, 204, 7, 240, 63,
0, 0, 140, 1, 0, 126,
0, 0, 12, 0, 0, 0,
192, 3, 12, 0, 0, 0,
224, 7, 12, 0, 12, 0,
48, 12, 6, 0, 63, 0,
48, 248, 3, 0, 254, 7,
24, 112, 0, 0, 252, 63,
24, 192, 1, 0, 28, 0,
28, 0, 7, 0, 31, 0,
12, 0, 14, 0, 28, 0,
14, 0, 12, 0, 15, 0,
6, 0, 12, 0, 0, 0,
7, 0, 12, 0, 0, 24,
3, 0, 12, 0, 0, 126,
0, 4, 15, 0, 128, 31,
0, 14, 12, 0, 248, 3,
128, 4, 12, 0, 30, 0,
192, 1, 12, 0, 60, 0,
128, 4, 14, 0, 240, 3,
0, 14, 15, 0, 128, 31,
0, 4, 12, 0, 0, 126,
0, 128, 7, 0, 0, 24,
0, 0, 0, 0, 0, 0,
0, 0, 192, 3, 14, 0,
0, 0, 0, 3, 63, 0,
0, 0, 0, 3, 254, 7,
0, 0, 128, 1, 252, 127,
0, 0, 192, 0, 28, 0,
0, 32, 64, 0, 15, 0,
0, 112, 96, 0, 0, 0,
0, 32, 48, 0, 0, 24,
0, 0, 16, 0, 0, 126,
0, 0, 24, 0, 192, 15,
0, 0, 12, 1, 252, 0,
0, 0, 140, 3, 31, 0,
0, 0, 12, 9, 124, 0,
0, 0, 12, 28, 224, 7,
0, 0, 12, 9, 128, 63,
0, 96, 134, 3, 0, 126,
0, 192, 3, 1, 0, 28,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 14, 0,
0, 0, 0, 0, 127, 0,
0, 0, 0, 0, 254, 7,
0, 0, 0, 0, 252, 63,
0, 0, 192, 15, 12, 0,
0, 0, 96, 28, 15, 0,
0, 0, 0, 24, 0, 0,
0, 0, 0, 24, 0, 0,
0, 0, 112, 24, 0, 0,
0, 0, 248, 24, 127, 0,
0, 0, 220, 24, 252, 15,
0, 0, 204, 25, 192, 63,
0, 0, 204, 13, 0, 0,
0, 0, 204, 7, 0, 0,
0, 0, 140, 3, 224, 7,
0, 0, 12, 0, 48, 12,
0, 0, 12, 0, 28, 28,
224, 1, 14, 0, 28, 28,
128, 255, 7, 0, 120, 12,
0, 0, 15, 0, 240, 7,
0, 0, 12, 0, 0, 0,
0, 0, 12, 0, 0, 0,
0, 224, 13, 0, 128, 3,
0, 176, 15, 0, 192, 7,
0, 24, 7, 0, 128, 3,
0, 24, 7, 0, 0, 0,
0, 24, 3, 0, 0, 0,
0, 16, 3, 0, 224, 7,
0, 0, 3, 0, 48, 12,
0, 128, 1, 0, 28, 28,
0, 128, 0, 0, 28, 28,
0, 0, 0, 0, 120, 12,
0, 0, 0, 0, 240, 7,
};unsigned char txt1[] = "ARM7 Example";
unsigned char txt2[] = "LPC2368 Family";
//-----------------------------------------------
void delay(void)
{
unsigned int i,j;
for(i=0; i<0xFFFF; i++)
for(j=0; j<0xFFFF; j++);
}
/**************************
* main proc
**************************/
void main(void)
{
nokia_init();
nokia_gotoxy(0,0);
nokia_putsf(txt1);
nokia_gotoxy(0,1);
nokia_putsf(txt2);
delay();
delay();
nokia_display_pitcher(pitcher1);
while(1);
این نوع LCD دارای 8 پایه است. ترتیب پایه ها به صورت زیر است:
1- VDD (3.3Volt)
2- SCK (Serial Clk)
3- SDIN (Serial Data)
4- DC (Select Data or Command

5- CS (Chip Select)
6- GND
7- V lcd
8- RST
خوشبختانه به علت یکسان بودن ولتاژ LCD موبایل 3310 و میکروکنترولر، پایه های LCD به صورت مستقیم به میکروکنترولر متصل می شود . اگر به پشت LCD نگاه کنید یک زایده نزدیک پایه یک مشاهده خوا هید کرد .
نقشه زیر برای آزمایش کردن LCD موبایل 3310 ببندید .
ببخشید نتونستم نقشه را کپی کنم ولی همان طوری که از برنامه معلوم است LCD را به میکروی LPC2368 و به پورت صفر وصل است بقیه پایه ها را نیز از متن برنامه بخوانید . پایه VLCD را با یک خازن 10نانو زمین کنید
پروژه جدید با نام LCD_3310 در مسیر PROJECTSبسازید .
فایلی با نام config.h بسازید و برنامه زیر را در آن بنویسید
/**************************
* File: config.h
**************************/
#ifndef _CONFIG_H
#define _CONFIG_H
#include "iolpc2368.h"
#define CCLK 4000000 //XTAL frequency in Hz (PLL is disable)
#define PCLK (CCLK/4) //asummed VPB divider is 4
#define TRUE 1
#define FALSE 0
#endif
/**************************
* end of file
**************************/
فایلی با نام config.c بسازید و برنامه زیر را در آن بنویسید
/**************************
* File: config.c
**************************/
#include "config.h"
/**************************
* end of file
**************************/
فایلی با نام nokia.h بسازید و برنامه زیر را در آن بنویسید
/**************************
* File: nokia.h
**************************/
#ifndef _NOKIA_H
#define _NOKIA_H
#include "config.h"
#define NOKIA_DIR IO0DIR
#define NOKIA_SET IO0SET
#define NOKIA_CLR IO0CLR
#define NOKIA_PIN IO0PIN
#define SCK (1<<22)
#define SDA (1<<21)
#define DC (1<<20)
#define CS (1<<19)
#define RST (1<<18)
#define NOKIA_MASK (0x00780800)
void nokia_init(void);
void nokia_clear(void);
void nokia_gotoxy(unsigned char , unsigned char);
void nokia_putsf(unsigned char *);
void nokia_command(unsigned char);
void nokia_char(unsigned char);
void nokia_puts(long);
void nokia_byte(unsigned char);
void nokia_display_pitcher(unsigned char *);
#endif
/**************************
* end of file
**************************/
فایلی با نام nokia.c بسازید و برنامه زیر را در آن بنویسید
/**************************
* File: lcd.c
**************************/
#include "config.h"
#include "nokia.h"
static void nokia_dorc(unsigned char);
static void nokia_delay(unsigned short);
uint8_t const font[][5]={
{0x00,0x00,0x00,0x00,0x00}, // SPACE
{0x00,0x00,0x2F,0x00,0x00}, // !
{0x00,0x07,0x00,0x07,0x00}, // "
{0x14,0x7F,0x14,0x7F,0x14}, // #
{0x2C,0x2A,0x7F,0x2A,0x12}, // $
{0x23,0x13,0x08,0x64,0x62}, // %
{0x36,0x49,0x55,0x22,0x50}, // &
{0x00,0x05,0x03,0x00,0x00}, // '
{0x00,0x1C,0x22,0x41,0x00}, // (
{0x00,0x41,0x22,0x1C,0x00}, // )
{0x14,0x08,0x3E,0x08,0x14}, // *
{0x08,0x08,0x3E,0x08,0x08}, // +
{0x00,0x50,0x30,0x00,0x00}, // ,
{0x08,0x08,0x08,0x08,0x08}, // -
{0x00,0x18,0x18,0x00,0x00}, // .
{0x20,0x10,0x08,0x04,0x02}, // /
{0x3E,0x51,0x49,0x45,0x3E}, // 0
{0x00,0x42,0x7F,0x40,0x00}, // 1
{0x42,0x61,0x51,0x49,0x46}, // 2
{0x21,0x41,0x45,0x4B,0x31}, // 3
{0x18,0x14,0x12,0x7F,0x10}, // 4
{0x27,0x45,0x45,0x45,0x39}, // 5
{0x3C,0x4A,0x49,0x49,0x30}, // 6
{0x01,0x71,0x09,0x05,0x03}, // 7
{0x36,0x49,0x49,0x49,0x36}, // 8
{0x06,0x49,0x49,0x29,0x1e}, // 9
{0x00,0x36,0x36,0x00,0x00}, // :
{0x00,0x56,0x36,0x00,0x00}, // ;
{0x08,0x14,0x22,0x41,0x00}, // <
{0x28,0x28,0x28,0x28,0x28}, // =
{0x00,0x41,0x22,0x14,0x08}, // >
{0x02,0x01,0x51,0x09,0x06}, // ?
{0x32,0x49,0x79,0x41,0x3E}, // @
{0x7E,0x11,0x11,0x11,0x7E}, // A
{0x7F,0x49,0x49,0x49,0x36}, // B
{0x3E,0x41,0x41,0x41,0x22}, // C
{0x7F,0x41,0x41,0x22,0x1C}, // D
{0x7F,0x49,0x49,0x49,0x41}, // E
{0x7F,0x09,0x09,0x09,0x01}, // F
{0x3E,0x41,0x49,0x59,0x7A}, // G
{0x7F,0x08,0x08,0x08,0x7F}, // H
{0x00,0x41,0x7F,0x41,0x00}, // I
{0x20,0x40,0x41,0x3F,0x01}, // J
{0x7F,0x08,0x14,0x22,0x41}, // K
{0x7F,0x40,0x40,0x40,0x40}, // L
{0x7F,0x02,0x0C,0x02,0x7F}, // M
{0x7F,0x04,0x08,0x10,0x7F}, // N
{0x3E,0x41,0x41,0x41,0x3E}, // O
{0x7F,0x09,0x09,0x09,0x06}, // P
{0x3E,0x41,0x51,0x21,0x5E}, // Q
{0x7F,0x09,0x19,0x29,0x46}, // R
{0x46,0x49,0x49,0x49,0x31}, // S
{0x01,0x01,0x7F,0x01,0x01}, // T
{0x3F,0x40,0x40,0x40,0x3F}, // U
{0x1F,0x20,0x40,0x20,0x1F}, // V
{0x3F,0x40,0x38,0x40,0x3F}, // W
{0x63,0x14,0x08,0x14,0x63}, // X
{0x07,0x08,0x70,0x08,0x07}, // Y
{0x61,0x51,0x49,0x45,0x43}, // Z
{0x00,0x7F,0x41,0x41,0x00}, // [
{0x15,0x16,0x7C,0x16,0x15}, // ??
{0x00,0x41,0x14,0x7F,0x00}, // ]
{0x04,0x02,0x01,0x02,0x04}, // ^
{0x40,0x40,0x40,0x40,0x40}, // _
{0x02,0x04,0x08,0x10,0x20}, /* \ */
{0x20,0x54,0x54,0x54,0x78}, // a
{0x7F,0x50,0x48,0x48,0x30}, // b
{0x38,0x44,0x44,0x44,0x20}, // c
{0x30,0x48,0x48,0x50,0x7F}, // d
{0x38,0x54,0x54,0x54,0x18}, // e
{0x08,0x7E,0x09,0x01,0x02}, // f
{0x0C,0x52,0x52,0x52,0x3E}, // g
{0x7F,0x08,0x04,0x04,0x78}, // h
{0x00,0x44,0x7D,0x40,0x00}, // i
{0x20,0x40,0X44,0x3D,0x00}, // j
{0x7F,0x10,0x28,0x44,0x00}, // k
{0x00,0x41,0x7F,0x40,0x00}, // l
{0x7C,0x04,0x18,0x04,0x78}, // m
{0x7C,0x08,0x04,0x04,0x78}, // n
{0x38,0x44,0x44,0x44,0x38}, // o
{0x7C,0x14,0x14,0x14,0x08}, // p
{0x08,0x14,0x14,0x18,0x7C}, // q
{0x7C,0x08,0x04,0x04,0x08}, // r
{0x48,0x54,0x54,0x54,0x20}, // s
{0x04,0x3F,0x44,0x40,0x20}, // t
{0x3C,0x40,0x40,0x20,0x7C}, // u
{0x1C,0x20,0x40,0x20,0x1C}, // v
{0x3C,0x40,0x30,0x40,0x3C}, // w
{0x44,0x28,0x10,0x28,0x44}, // x
{0x0C,0x50,0x50,0x50,0x3C}, // y
{0x44,0x64,0x54,0x4C,0x44}, // z
{0x00,0x08,0x36,0x41,0x00}, // {
{0x00,0x00,0x7F,0x00,0x00}, // |
{0x00,0x41,0x36,0x08,0x00}, // }
{0x08,0x08,0x2A,0x1C,0x08}, // ->
{0x08,0x1C,0x2A,0x08,0x08} // <-
};
/**************************
* nokia command()
**************************/
void nokia_command(unsigned char data)
{
NOKIA_CLR |= (DC|CS);
nokia_dorc(data);
NOKIA_SET |= CS;
}
/**************************
* nokia byte()
**************************/
void nokia_byte(unsigned char data)
{
NOKIA_SET |= DC;
NOKIA_CLR |= CS;
nokia_dorc(data);
NOKIA_SET |= CS;
}
/**************************
* nokia dorc()
**************************/
void nokia_dorc(unsigned char data)
{
unsigned char i;
for (i=0;i<8;i++)
{
NOKIA_CLR |= SDA;
if( data & ( 1 << (7-i) ) ) NOKIA_SET |= SDA;
NOKIA_CLR |= SCK;
NOKIA_SET |= SCK;
}
}
/**************************
* nokia data()
**************************/
void nokia_char(unsigned char data)
{
unsigned char i;
for (i=0;i<5;i++)
nokia_byte(font[data-32][i]);
nokia_byte(0);
}
/**************************
* nokia Init()
**************************/
void nokia_init(void)
{
NOKIA_DIR|=NOKIA_MASK; // set lcd data lines to output
NOKIA_SET |= NOKIA_MASK;
nokia_delay(200);
NOKIA_CLR |= RST;
nokia_delay(200);
NOKIA_SET |= RST;
nokia_command(0x21);
nokia_command(0xc2);
nokia_command(0x13);
nokia_command(0x20);
nokia_command(0x09);
nokia_clear();
nokia_delay(200);
nokia_command(0x08);
nokia_delay(200);
nokia_command(0x0c);
nokia_clear();
}
/**************************
* nokia_putsf()
**************************/
void nokia_putsf(unsigned char *p)
{
while(*p !='\0'

}
/**************************
* nokia_display pitcher()
**************************/
void nokia_display_pitcher(unsigned char *p)
{
unsigned char i,j;
nokia_command(0x22);
nokia_gotoxy(0,0);
for(i=0 ; i<6 ;i++)
{
for(j=0 ; j<84 ; j++)
nokia_byte(*(p++));
}
nokia_command(0x20);
}
/**************************
* nokia gotoxy()
**************************/
void nokia_gotoxy(unsigned char x, unsigned char y)
{
y &= 7;
nokia_command((y|=0x40));
nokia_command((x|=0x80));
}
/**************************
* nokia delay()
**************************/
void nokia_delay(unsigned short time)
{
unsigned short i,j;
for(i=0;i<time;i++)
for(j=0;j<1000;j++);
}
/**************************
* nokia clear()
**************************/
void nokia_clear(void)
{
unsigned char i,j;
nokia_gotoxy(0,0);
for(i=0 ; i < 6 ; i++)
{
for(j=0 ; j < 84 ; j++)
nokia_byte(0);
}
}
/**************************
* nokia_puts()
**************************/
void nokia_puts(long Num)
{
unsigned char temp[16],i,j,k;
if (Num<0)
{
Num=-Num;
nokia_char('-'

}
for(i=0;i<16;i++)
temp[i]=0;
j=0;
do
{
temp[j++] = '0' + Num % 10;
Num=Num/10;
} while (Num > 0);
for(i=0;i<=((j-1)/2);i++)
{
k=temp[i];
temp[i]=temp[j-i-1];
temp[j-i-1]=k;
}
temp[j]='\0';
nokia_putsf(temp);
}
/**************************
* end of file
**************************/
فایلی با نام main.c بسازید و برنامه زیر را در آن بنویسید
/**************************
* main.c
**************************/
#include "config.h"
#include "nokia.h"
unsigned char pitcher1[]=
{
0, 0, 192, 15, 0, 0,
0, 0, 112, 28, 128, 3,
0, 0, 0, 24, 192, 7,
0, 0, 0, 24, 128, 3,
0, 0, 96, 24, 0, 0,
0, 0, 248, 24, 28, 0,
0, 0, 204, 24, 126, 0,
0, 0, 204, 29, 115, 0,
0, 0, 204, 13, 254, 3,
0, 0, 204, 7, 240, 63,
0, 0, 140, 1, 0, 126,
0, 0, 12, 0, 0, 0,
192, 3, 12, 0, 0, 0,
224, 7, 12, 0, 12, 0,
48, 12, 6, 0, 63, 0,
48, 248, 3, 0, 254, 7,
24, 112, 0, 0, 252, 63,
24, 192, 1, 0, 28, 0,
28, 0, 7, 0, 31, 0,
12, 0, 14, 0, 28, 0,
14, 0, 12, 0, 15, 0,
6, 0, 12, 0, 0, 0,
7, 0, 12, 0, 0, 24,
3, 0, 12, 0, 0, 126,
0, 4, 15, 0, 128, 31,
0, 14, 12, 0, 248, 3,
128, 4, 12, 0, 30, 0,
192, 1, 12, 0, 60, 0,
128, 4, 14, 0, 240, 3,
0, 14, 15, 0, 128, 31,
0, 4, 12, 0, 0, 126,
0, 128, 7, 0, 0, 24,
0, 0, 0, 0, 0, 0,
0, 0, 192, 3, 14, 0,
0, 0, 0, 3, 63, 0,
0, 0, 0, 3, 254, 7,
0, 0, 128, 1, 252, 127,
0, 0, 192, 0, 28, 0,
0, 32, 64, 0, 15, 0,
0, 112, 96, 0, 0, 0,
0, 32, 48, 0, 0, 24,
0, 0, 16, 0, 0, 126,
0, 0, 24, 0, 192, 15,
0, 0, 12, 1, 252, 0,
0, 0, 140, 3, 31, 0,
0, 0, 12, 9, 124, 0,
0, 0, 12, 28, 224, 7,
0, 0, 12, 9, 128, 63,
0, 96, 134, 3, 0, 126,
0, 192, 3, 1, 0, 28,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 14, 0,
0, 0, 0, 0, 127, 0,
0, 0, 0, 0, 254, 7,
0, 0, 0, 0, 252, 63,
0, 0, 192, 15, 12, 0,
0, 0, 96, 28, 15, 0,
0, 0, 0, 24, 0, 0,
0, 0, 0, 24, 0, 0,
0, 0, 112, 24, 0, 0,
0, 0, 248, 24, 127, 0,
0, 0, 220, 24, 252, 15,
0, 0, 204, 25, 192, 63,
0, 0, 204, 13, 0, 0,
0, 0, 204, 7, 0, 0,
0, 0, 140, 3, 224, 7,
0, 0, 12, 0, 48, 12,
0, 0, 12, 0, 28, 28,
224, 1, 14, 0, 28, 28,
128, 255, 7, 0, 120, 12,
0, 0, 15, 0, 240, 7,
0, 0, 12, 0, 0, 0,
0, 0, 12, 0, 0, 0,
0, 224, 13, 0, 128, 3,
0, 176, 15, 0, 192, 7,
0, 24, 7, 0, 128, 3,
0, 24, 7, 0, 0, 0,
0, 24, 3, 0, 0, 0,
0, 16, 3, 0, 224, 7,
0, 0, 3, 0, 48, 12,
0, 128, 1, 0, 28, 28,
0, 128, 0, 0, 28, 28,
0, 0, 0, 0, 120, 12,
0, 0, 0, 0, 240, 7,
};unsigned char txt1[] = "ARM7 Example";
unsigned char txt2[] = "LPC2368 Family";
//-----------------------------------------------
void delay(void)
{
unsigned int i,j;
for(i=0; i<0xFFFF; i++)
for(j=0; j<0xFFFF; j++);
}
/**************************
* main proc
**************************/
void main(void)
{
nokia_init();
nokia_gotoxy(0,0);
nokia_putsf(txt1);
nokia_gotoxy(0,1);
nokia_putsf(txt2);
delay();
delay();
nokia_display_pitcher(pitcher1);
while(1);
دیدگاه