图形点阵式液晶显示器MSP-G320240在高速处
4 C语言程序设计
TMS320F206的用户可以用汇编语言或C语言进行源程序的编写,因为用C语言开发出的系统易于维护,可靠性高,可移植性好。下面是用C语言编写的液晶显示器MSP-G320240的初始化及清屏程序:
ioport unsigned int port1ff1; /*定义片选地址*/
ioport unsigned int port1ff0;
#define Lcd_wc port1ff1 /*LCD写指令*/
#define Lcd_wd port1ff0 /*LCD写参数*/
#define Lcd_rs port1ff0
#define Lcd_rd port1ff1
#define SYSTEM_SET 0x40 /*初始化设置*/
#define SCROLL 0x44 /*显示域设置*/
#define SLEEP_IN 0x53 /*休闲模式设置*/
#define DISP_ON 0x59 /*显示状态设置显示开*/
#define DISP_OFF 0x58 /*显示关*/
#define OVLAY 0x5b /*显示合成设置*/
#define HDOT_SCR 0x5a /*点位移设置*/
#define CSRFORM 0x5d /*光标形状设置*/
#define CGRAM_ADR 0x5c /*CGRAM首址设置*/
#define CSRDIR_RG 0x4c /*光标移动方式设置光标右移*/
#define CSRDIR_LF 0x4d /*光标左移*/
#define CSRDIR_UP 0x4e /*光标上移*/
#define CSRDIR_DW 0x4f /*光标下移*/
#define CSRW 0x46 /*光标指针设置*/
#define CSRR 0x47 /*读取光标指针*/
#define MWRITE 0x42 /*数据写入设置*/
#define MREAD 0x43 /*数据读取设置*/
#define Lcd AP 0x28 /*显示屏一行所占字节数*/
#define wait() while((Lcd_rs&0x0040)==0x0040)/*等待*/
void Clear(unsigned int Add1,unsigned int Add2,unsigned int Data)
{unsigned int Counter;
Lcd_wc=CSRDIR_RG;wait();/*Add1: 显示区首址*/
Lcd_wc=CSRW; wait();/*Add2: 显示区末址 */
Lcd_wd=0x00; wait(); /*Data: 显示数据*/
Lcd_wd=0x00;wait();
Lcd wc=MWRITE; wait();
{for_Counter=Add1;Counter<Add2;Counter++)
{Lcd_wd=Data;wait();}
Lcd_wc=CSRDIR_DW; wait();}
void Lcd_Init( void) /*初始化液晶子程序*/
{unsigned int i; Lcd_wc=SYSTEM_SET; wait();
for(i=0;i<8;i++)/* Systab[]=0x30,0x87,
0x07,0x27,0x42,0xf0,0x28,0*/
{ Lcd_wd=Systab[i];wait();}Lcd_wc=
SCROLL; wait();
for(i=0;i<10;i++) /*Scrtab[]=0,0,
0xf0,0,0x40,0xf0,0,0x80,0,0x00*/
{Lcd_wd=Scrtab[i];wait(); Lcd_wc=
HDOT_SCR; wait(0;
Lcd_wd=0x00; wait();Lcd_wc=OVLAY;
wait();Lcd_ wd=0x08;wait();
Lcd_Clear(0,0x8000,0x00); /* 清显示区子程序*/
Lcd_wc=DISP_ON; wait();Lcd_wd=
0x54;wait(); /*0x54*/
Lcd_wc=CSRFORM;wait();Lcd_wd=0x07;
wait();
Lcd_wd=0x87;wait();
Lcd_wc=CSRDIR_DW;wait();