⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcdsenddata.c

📁 Fujitsu MB89P475的应用实例
💻 C
字号:
#define		HT1621_DATA  P16
#define		HT1621_CLK	 P15
#define		HT1621_CS	 P14
// Command
#define CommandID	0x80		//3bit
#define SysDis 		0x00
#define SysEn  		0x01
#define LcdOff 		0x02
#define LcdOn  		0x03
#define	WDTDis		0x05
#define	TONEOFF		0X08
#define	ClrWDT		0x0e
#define XTAL32K		0X14
#define RC256K		0x18
#define Bias12Com2 	0x20	
#define Bias12Com3 	0x24	
#define Bias12Com4 	0x28	

#define Bias13Com2 	0x21
#define Bias13Com3 	0x25
#define Bias13Com4 	0x29

#define	IRQ_DIS 	0X80
#define NORMAL  	0Xe3

// Data
#define	DataID		 0xa0    		// 3bit
#define StartAddress 0x00			//0010-00--->0010-0000   6bit  ,操作HT1621的起始地址


void Command(unbyte Command,unbyte Bits); //Command 是命令,Bits是命令的位数
void SendHight_Low(unbyte Level);             //Level 是电平信号 :Hight or Low
void SendAddress(unbyte Address,unbyte Bits);   // Address是操作Lcd起始地址,Bits 是位数
void SendSegData(unbyte *StartSeg,unbyte Bytes,unbyte Bits);//*Startseg是要发送的数据的起始地址*/

//============================================================
//===========                  *******                  ======
//===========                     * *                   ======
//===========                      *                    ======
//===========      **      **************               ======
//===========       **     *            *               ======
//===========    *******   *      *     *               ======
//===========        **    *   ******   *               ======
//===========       **     *      *     *               ======
//===========         *    *   ******   *               ======
//===========       **     *      *     *               ======
//===========      **      *      *   * *               ======
//===========       **     *           **               ======
//===========        **                                 ======
//===========         ************************          ======
//===========                                           ======
//============================================================
//===========                                           ======
//===========              ************                 ======
//===========      **                 **                ======
//===========       **         *      **                ======
//===========    *******       *       **               ======
//===========        **     *********  **               ======
//===========       **         *        **              ======
//===========         *        *        **              ======
//===========       **         *         **   *         ======
//===========      **          *         **  **         ======
//===========       **                    ****          ======
//===========        **                                 ======
//===========         ******************************    ======
//===========                                           ======
//============================================================
//============================================================
//============================================================
//============================================================
//============================================================
//============================================================
Lcd_Display()
{
	if (!LcdResetFlag)
		{
			HT1621_CS=false;
			LcdResetFlag=true;
			HT1621_CS=false;
			Command(CommandID,3);
			Command(RC256K,8);
			Command(SysDis,8);
			Command(WDTDis,8);
			Command(WDTDis,8);
			Command(LcdOff,8);
			Command(SysEn,8);
			Command(LcdOn,8);
			Command(Bias13Com4,8);

			HT1621_CS=true;nop;nop;nop;nop;
		}	
		
	HT1621_CS=false;
	Command(DataID,3);
	SendAddress(StartAddress,6);			//LcdRam start at 0x00h
	SendSegData(&Seg0_Seg1.byte,15,8);    // 要发送数据的起始地址、字节数、每一字节的位数
	HT1621_CS=true;nop;nop;nop;
	
}

//=================================
void SendSegData(unbyte *StartSeg,unbyte Bytes,unbyte Bits)
{
	unbyte i,k;
	WDTC.byte=0x05;
	for	(i=0;i<Bytes;i++)
		{
			k=*StartSeg;
			for	(j=0;j<Bits;j++)
				{
					if (k&0x01)					
						{SendHight_Low(true);}
					else
						{SendHight_Low(false);}	
					k/=2;	
				}
			StartSeg++;	
		}
}
//=================================
void	SendAddress(unbyte  Address,unbyte Bits)
{
	unbyte i;
	WDTC.byte=0x05;
	for	(i=0;i<Bits;i++)	
		{
			if (Address&0x80)
				{
					SendHight_Low(true);
				}
			else
				{
					SendHight_Low(false);
				}	
			Address*=2;	
		}
}
//=================================
void Command(unbyte Command,unbyte Bits)
{
	unbyte k;
	WDTC.byte=0x05;
	for (k=0;k<Bits;k++)	
		{
			if (Command&0x80)			
				{
					SendHight_Low(true);
				}
			else
				{
					SendHight_Low(false);
				}	
			Command*=2;	
		}

	if (Bits==8)		//判断是发送命令还是ID号
	{SendHight_Low(false);}
}

void SendHight_Low(unbyte Level)
{
	HT1621_CLK=false;
	nop;nop;nop;nop;
	nop;nop;nop;nop;
	WDTC.byte=0x05;
	if (Level)
		{
			HT1621_DATA=true;		// send "1"
		}
	else
		{
			HT1621_DATA=false;		// send "0"
		}	
	nop;nop;nop;nop;
	nop;nop;nop;nop;
	HT1621_CLK=true;	
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -