各位,我用launchpad调诺基亚5110屏的程序,程序中只要有 LCD_clear(); 就无法执行,屏蔽 LCD_clear(); 之后只能显一部分,LCD_clear();检查觉得也没问题,可就是执行不了,怎么解决?
# include "msp430g2553.h"
# include "nokia_5110.h"
# include "english_6x8_pixel.h"
# include "write_chinese_string_pixel.h"
void delay_1us(void)
{
unsigned int i;
for(i=0;i<1000;i++);
}
void delay_1ms(void)
{
unsigned int i;
for (i=0;i<1140;i++);
}
void delay_nms(unsigned int n)
{
unsigned int i=0;
for (i=0;i
delay_1ms();
}
void LCD_init(void)
{
LCD_RST_0;
delay_1us();
LCD_RST_1;
LCD_CE_0;
delay_1us();
LCD_CE_1;
delay_1us();
LCD_write_byte(0x21, 0); // ê1ó?à??1?üá?éè??LCD?£ê?
LCD_write_byte(0xC0, 0); // éè??????μ??1
LCD_write_byte(0x06, 0); // ???èD£?y
LCD_write_byte(0x13, 0); // 1:48
LCD_write_byte(0x20, 0); // ê1ó??ù±??üá?
LCD_clear(); // ???á
LCD_write_byte(0x0c, 0); // éè?¨??ê??£ê?£??y3£??ê?
LCD_CE_0;
}
void LCD_clear(void)
{
unsigned int k;
LCD_write_byte(0x0c, 0);
LCD_write_byte(0x80, 0);
for(k=0; k<504; k++)
LCD_write_byte(0, 1);
}
void LCD_set_XY(unsigned char X, unsigned char Y)
{
LCD_write_byte(0x40|Y,0); // column
LCD_write_byte(0x80|X,0); // row
}
void LCD_write_char(unsigned char c)
{
unsigned char line;
c -= 32;
for (line=0; line<6; line++)
LCD_write_byte(font6x8[c][line], 1);
}
void LCD_write_english_string(unsigned char X,unsigned char Y,char *s)
{
LCD_set_XY(X,Y);
while (*s)
{
LCD_write_char(*s);
s++;
}
}
void LCD_write_chinese_string(unsigned char X, unsigned char Y,
unsigned char ch_with,unsigned char num,
unsigned char line,unsigned char row)
{
unsigned char i,n;
LCD_set_XY(X,Y); //éè??3?ê?????
for (i=0;i
{
for (n=0; n
{
if (n==ch_with) //D′oo×?μ???°?2?·?
{
if (i==0) LCD_set_XY(X,Y+1);
else
LCD_set_XY((X+(ch_with+row)*i),Y+1);
}
LCD_write_byte(write_chinese[line+i][n],1);
}
i++;
LCD_set_XY((X+(ch_with+row)*i),Y);
}
}
void LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map,
unsigned char Pix_x,unsigned char Pix_y)
{
unsigned int i=0,n=0;
unsigned char row=0;
if (Pix_y%8==0) row=Pix_y/8; //??????í??ù??DDêy
else
row=Pix_y/8+1;
for (n=0;n
{
LCD_set_XY(X,Y);
for(i=0; i
{
LCD_write_byte(map[i+n*Pix_x], 1);
}
Y++; //??DD
}
}
void LCD_write_byte(unsigned char dat, unsigned char command)
{
unsigned char i;
LCD_CE_0;
if(command == 0)
LCD_DC_0;
else
LCD_DC_1;
for(i=0;i<8;i++)
{
if(dat&0x80)
SDIN_1;
else
SDIN_0;
SCLK_0;
dat = dat << 1;
SCLK_1;
}
LCD_CE_1;
}
void IO_init()
{
P1DIR=0xff; // 初始化IO
P1OUT=0x00;
P2DIR=0xff; // 初始化IO
P2OUT=0x00;
}
void main(void)
{
IO_init(); LED1_1;
LCD_init(); //初始化液晶
LCD_clear();
while(1)
{
LCD_write_english_string(0,0,"a");
LCD_write_english_string(2,2,"a");
LCD_write_english_string(4,4,"a");
//LCD_write_english_string(0,0," Welcome to ");
LED2_1;
//LCD_write_english_string(2,2," Welcome to ");
LCD_write_english_string(3,3,"A");
LCD_write_english_string(4,4,"A");
//LCD_write_english_string(0,1," Amy studio ");
//LCD_write_english_string(0,2,"amy-studio.com");
//LCD_write_english_string(0,3," Nokia5110 LCD");
//LCD_write_chinese_string(12,4,12,4,0,5);
}
}