找回密码
 注册会员
搜索附件  

eighteen.rar

 

关于LGM12864显示字的问题:
本人学习单片机书是应用gccavr软件,现在是将gcc改为icc程序,在gcc中能够很好的实现,但改为icc显示就不对了。希望大侠们指点一下。在下先谢谢了。下面是我的代码。附件中有我的程序和仿真图。
//LCD12864显示程序
#include<iom16v.h>
#include<Delay.h>
#include<string.h>
#include<macros.h>
#define INT8U unsigned char
#define INT16U unsigned int
#define LCD_START_ROW 0xC0
#define LCD_PAGE 0xB8
#define LCD_COL 0x40
#define RW PD0
#define DI PD1
#define E PD2
#define CS1 PD3
#define CS2 PD4
#define RST PD5
#define LCD_PORT PORTC
#define LCD_DDR DDRC
#define LCD_PIN PINC
#define LCD_CTRL PORTD
#define RW_1() LCD_CTRL|=(1<<RW)
#define RW_0() LCD_CTRL&=~(1<<RW)
#define DI_1() LCD_CTRL|=(1<<DI)
#define DI_0() LCD_CTRL&=~(1<<DI)
#define E_1() LCD_CTRL|=(1<<E)
#define E_0() LCD_CTRL&=~(1<<E)
#define CS1_1() LCD_CTRL|=(1<<CS1)
#define CS1_0() LCD_CTRL&=~(1<<CS1)
#define CS2_1() LCD_CTRL|=(1<<CS2)
#define CS2_0() LCD_CTRL&=~(1<<CS2)
#define RST_1() LCD_CTRL|=(1<<RST)
#define RST_0() LCD_CTRL&=~(1<<RST)
INT8U Reverse_Display=0;
void Wait_LCD_Ready()
{
Check_Busy:
LCD_DDR=0x00;
LCD_PORT=0xFF;
RW_1();asm("nop");DI_0();
E_1(); asm("nop");E_0();
if(LCD_PIN&0x80)
goto Check_Busy;
}
void LCD_Write_Command(INT8U cmd)
{
Wait_LCD_Ready();
LCD_DDR=0xFF;
LCD_PORT=0xFF;
RW_0();asm("nop");DI_0();
LCD_PORT=cmd;
E_1();asm("nop");E_0();
}
void LCD_Write_Data(INT8U dat)
{
Wait_LCD_Ready();
LCD_DDR=0xFF;
LCD_PORT=0xFF;
RW_0();asm("nop");DI_1();
if(!Reverse_Display)
LCD_PORT=dat;
else
LCD_PORT=~dat;
E_1();asm("nop");E_0();
}
void LCD_Initialize(void)
{
LCD_Write_Command(0x3F);
DelayMs(15);
}
//从第P页第L列开始显示W个字节数据,数据在r所指向的缓冲
void Common_Show(INT8U P,INT8U L,INT8U W,INT8U *r)
{
INT8U i;
if(L<64)
{
CS1_1();CS2_0();
LCD_Write_Command(LCD_PAGE+P);
LCD_Write_Command(LCD_COL+L);
if(L+W<64)
{
for(i=0;i<W;i++)
LCD_Write_Data(r);
}
else
{
for(i=0;i<64-L;i++)
LCD_Write_Data(r);
CS1_0();CS2_1();
LCD_Write_Command(LCD_PAGE+P);
LCD_Write_Command(LCD_COL);
for(i=64-L;i<W;i++)
LCD_Write_Data(r);
}
}
else
{
CS1_0();CS2_1();
LCD_Write_Command(LCD_PAGE+P);
LCD_Write_Command(LCD_COL+L-64);
for(i=0;i<W;i++)
LCD_Write_Data(r);
}
}
//8*116点阵
void Display_A_Char_8X16(INT8U P,INT8U L,INT8U *M)
{
Common_Show(P,L,8,M);
Common_Show(P+1,L,8,M+8);
}
//16*16点阵
void Display_A_WORD(INT8U P,INT8U L,INT8U *M)
{
Common_Show(P,L,16,M);
Common_Show(P+1,L,16,M+16);
}
//一串16*16点阵
void DisPlay_A_WORD_String(INT8U P,INT8U L,INT8U C,INT8U *M)
{
INT8U i;
for(i=0;i<C;i++)
{
Display_A_WORD(P,L+i*16,M+i*32);
}
}

//主程序
#include<iom16v.h>
//#include<Delay.h>
#define INT8U unsigned char
#define INT16U unsigned int
extern void LCD_Initialize(void);
extern void DisPlay_A_WORD_String(INT8U P,INT8U L,INT8U C,INT8U *M);
extern INT8U Reverse_Display;
const INT8U WORD_Dot_Matrix[]=
{
/*-- 文字: 液 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x61,0x06,0xE0,0x18,0x84,0xE4,0x1C,0x84,0x65,0xBE,0x24,0xA4,0x64,0x04,0x00,
0x04,0x04,0xFF,0x00,0x01,0x00,0xFF,0x41,0x21,0x12,0x0C,0x1B,0x61,0xC0,0x40,0x00,
/*-- 文字: 晶 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0x00,0x00,0x7E,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x7E,0x00,0x00,0x00,0x00,
0x00,0x7F,0x25,0x25,0x25,0x25,0x7F,0x00,0x00,0x7F,0x25,0x25,0x25,0x25,0x7F,0x00,
/*-- 文字: 屏 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xFF,0x09,0x49,0x59,0xE9,0x49,0x49,0x49,0xE9,0x59,0x49,0x4F,0x00,0x00,
0x40,0x30,0x0F,0x82,0x42,0x32,0x0F,0x02,0x02,0x02,0xFF,0x02,0x02,0x02,0x02,0x00,
/*-- 文字: 测 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x08,0x31,0x86,0x60,0x00,0xFE,0x02,0xF2,0x02,0xFE,0x00,0xF8,0x00,0x00,0xFF,0x00,
0x04,0xFC,0x03,0x00,0x80,0x47,0x30,0x0F,0x10,0x67,0x00,0x07,0x40,0x80,0x7F,0x00,
/*-- 文字: 试 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x40,0x42,0xDC,0x08,0x00,0x90,0x90,0x90,0x90,0x90,0xFF,0x10,0x12,0x1C,0x10,0x00,
0x00,0x00,0x7F,0x20,0x10,0x20,0x20,0x1F,0x10,0x10,0x01,0x06,0x18,0x20,0x78,0x00,
/*-- 文字: 程 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0xBF,0x80,0x00,0x00,
0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x40,0x00,
/*-- 文字: 序 --*/
/*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/
0x00,0x00,0xFC,0x04,0x04,0x14,0x14,0x35,0x56,0x94,0x54,0x34,0x14,0x04,0x04,0x00,
0x80,0x60,0x1F,0x00,0x01,0x01,0x01,0x41,0x81,0x7F,0x01,0x01,0x01,0x03,0x01,0x00,
};
void main()
{
DDRD=0xFF;PORTD=0xFF;
LCD_Initialize();
DisPlay_A_WORD_String(2,8,7,(INT8U*)WORD_Dot_Matrix);
Reverse_Display=1;
DisPlay_A_WORD_String(5,8,7,(INT8U*)WORD_Dot_Matrix);
while(1);
}


QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-24 01:26 , Processed in 0.039899 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

返回顶部