本帖最后由 芯圣电子官方QQ 于 2023-7-25 11:07 编辑
为便于编程所作的输出高低电平的宏定义为: #define LCD_LED_High() LED=1
#define LCD_CLK_H SCK=1 #define LCD_CLK_L SCK=0
#define LCD_DIN_H SDI=1 #define LCD_DIN_L SDI=0
#define LCD_DC_H DC=1 #define LCD_DC_L DC=0
#define LCD_RST_H RST=1 #define LCD_RST_L RST=0
#define LCD_CS_H SEC=1 #define LCD_CS_L SEC=0
配置各引脚输出功能的函数为:
void LCD_GPIO_Cogfig(void)
{
P2M4 = 0xC2;
P3M5 = 0xC2;
P3M4 = 0xC2;
P3M3 = 0xC2;
P2M1 = 0xC2;
P1M7 = 0xC2;
LED=1;
}
单字符显示函数为:
void LCD_printc(unsigned char x, unsigned char y, unsigned char c_dat)
{
unsigned char i, j,u;
u =c_dat-32;
x <<= 3;
y <<= 1;
for(j = 0; j < 2; j++)
{
LCD_pos_byte(x, (y + j));
for(i = 0; i < 8; i++)
LCD_write_dat(Font_code[u][8 * j + i]);
}
}
字符串显示函数为:
void LCD_prints(unsigned char x, unsigned char y, unsigned char *s_dat)
{
while(*s_dat && x < 10)
{LCD_printc(x++, y, *s_dat); s_dat++;}
}
void LCD5510_Init(void)
{
LCD_GPIO_Cogfig();
mdelay(800);
LCD_reset_hard;
LCD_write_cmd(0x21);
LCD_write_cmd(0x06);
LCD_write_cmd(0x13);
LCD_write_cmd(0xc8);
LCD_write_cmd(0x20);
LCD_write_cmd(0x0c);
LCD_write_cmd(Y_Page_Addr);
LCD_write_cmd(X_Col_Addr);
LCD_clr_scr();
}
实现演示效果的主程序如下:
void main(void)
{
while((CLKCON&0x20)!=0x20);
CLKSWR = 0x51;
while((CLKSWR&0xC0)!=0x40);
CLKDIV = 0x01;
P0M0 = 0xC2;
LED4 = 0;
LCD5510_Init();
LCD5510_Init();
while(1)
{
LED4 =0;
LCD_prints(0,0,"abcdefghijk");
LCD_prints(0,1,"lmnopqrstuv");
LCD_prints(0,2,"wxyz{|}~");
delay();
delay();
delay();
LED4 = 1;
LCD_prints(0,0,"ABCDEFGHIJK");
LCD_prints(0,1,"LMNOPQRSTUV");
LCD_prints(0,2,"WXYZ");
delay();
delay();
delay();
}
}
LCD5110显示屏是一款显示内容相对丰富,能耗相对比较低的显示器件,为实现显示功能它与SDK-HC89F0541开发板的连接关系为: SEC --- P2_4 RST --- P3_5 DC --- P3_4 SDI --- P3_3 SCK --- P1_6 LED --- P1_7
|