內(nèi)藏T6963C控制器的液晶模塊的顯示
器的液晶顯示模塊的接口技術(shù)。本實(shí)驗(yàn)采用的是間接訪問方式。
下面的程序都是通用的,如果要實(shí)現(xiàn)某一功能只要調(diào)用相應(yīng)的子程序即可。調(diào)用子程序時(shí)只需在主程序
里調(diào)用相應(yīng)的演示子程序,而寫入程序由它的演示子程序調(diào)用。
一、C51程序:
/************************************************************************
圖形液晶模塊CA12864R的控制
T6963C
zhaojun
2008-1-19
*************************************************************************/
/****************** LCD12864指令 ********************************/
#include
#include
#include
/****************** LCD12864接線引腳定義 *************************/
#define LCM_WR P3_2 // 寫操作信號
#define LCM_RD P3_3 // 讀操作信號
#define LCM_CD P3_4 // 通道選擇信號
#define LCM_DATAP1 // 顯示數(shù)據(jù)端口
#define uchar unsigned char
#define uint unsigned int
uchar code CCTAB [1024]={
/*-- 寬度x高度=128x64 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xF0,0x00,0x00,0x15,0x2A,0x00,0x00,0xF0,0x00,0x00,0xA8,0xA0,0x00,0x7C,0x00,
0x00,0xF0,0x00,0x00,0x00,0x55,0x00,0x03,0xC0,0x1F,0x00,0x54,0x00,0x00,0x7C,0x00,
0x00,0xF1,0xFF,0xFF,0x94,0xAA,0x0F,0xC7,0x80,0x11,0x80,0xA8,0xA9,0xFC,0x7C,0x00,
0x00,0xF3,0xFF,0xFF,0xA8,0x55,0x03,0xFF,0xF8,0x60,0xC0,0x51,0x54,0xFE,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x14,0xAA,0x0F,0xFF,0xC0,0xDC,0x40,0x02,0xAA,0x06,0x7C,0x00,
0x00,0xF2,0x01,0x40,0x28,0x50,0x01,0xFF,0xFF,0xBE,0x41,0x45,0x54,0x06,0x7C,0x00,
0x00,0xF0,0xA2,0xA0,0x00,0x07,0xDF,0xFF,0x00,0x7E,0x62,0xA2,0xAA,0x06,0x7C,0x00,
0x00,0xF1,0x51,0x40,0x00,0x18,0xFF,0xFE,0x00,0x7E,0x21,0x45,0x54,0x06,0x7C,0x00,
0x00,0xF0,0xA2,0x80,0x00,0x21,0x9F,0xFC,0x00,0x1F,0x22,0xA2,0xAA,0x06,0x7C,0x00,
0x00,0xF1,0x50,0x00,0x00,0x46,0x3F,0xFC,0x00,0x07,0x21,0x45,0x54,0x06,0x7C,0x00,
0x00,0xF0,0xA2,0xA0,0x00,0x5C,0x7F,0x78,0x00,0x03,0x20,0x02,0xA8,0x06,0x7C,0x00,
0x00,0xF0,0x05,0x50,0x00,0x38,0xEE,0x78,0x00,0x00,0x60,0x01,0x50,0x06,0x7C,0x00,
0x00,0xF2,0x0A,0xA0,0x00,0x30,0xDC,0x70,0x00,0x00,0x30,0x00,0x00,0x06,0x7C,0x00,
0x00,0xF5,0x15,0x50,0x00,0x61,0x98,0x70,0x00,0x00,0x18,0x00,0x00,0x06,0x7C,0x00,
0x00,0xF2,0xAA,0xA0,0x00,0xC1,0x38,0x60,0x00,0x00,0x0C,0x00,0x00,0x00,0x7C,0x00,
0x00,0xF5,0x15,0x50,0x01,0x82,0x30,0x60,0x00,0x00,0x04,0x00,0x00,0x14,0x7C,0x00,
0x00,0xF0,0x2A,0xA0,0x53,0x02,0x20,0x40,0x00,0x00,0x06,0x00,0x00,0x2A,0x7C,0x00,
0x00,0xF3,0x15,0x40,0xA2,0x00,0x20,0x40,0x00,0x00,0x0E,0x00,0x0A,0x14,0x7C,0x00,
0x00,0xF3,0x2A,0x80,0x56,0x00,0x00,0x40,0x00,0x00,0x1F,0x00,0x15,0x2A,0x7C,0x00,
0x00,0xF3,0x15,0x00,0xA4,0x00,0x00,0x00,0x00,0x00,0x39,0x00,0x0A,0x14,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x15,0x00,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x0A,0x15,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x2A,0xFC,0x00,
0x00,0xF3,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x0E,0x80,0x00,0x55,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x28,0xAA,0xFC,0x00,
0x00,0xF3,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x50,0x55,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x28,0xAA,0xFC,0x00,
0x00,0xF3,0x00,0x14,0x08,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x50,0x55,0x7C,0x00,
0x00,0xF3,0x00,0x28,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0xAA,0xFC,0x00,
0x00,0xF3,0x05,0x14,0x07,0xFC,0x0F,0xFF,0xF0,0x80,0x18,0xC0,0x00,0x55,0x7C,0x00,
0x00,0xF3,0x0A,0xA8,0x0C,0x1C,0x08,0x00,0x1F,0x80,0x78,0xC0,0x00,0x2A,0x7C,0x00,
0x00,0xF3,0x15,0x00,0x0C,0x08,0x08,0x00,0x1C,0x80,0x78,0xC0,0x00,0x00,0x7C,0x00,
0x00,0xF3,0x0A,0x80,0x0A,0x10,0x04,0x00,0x0C,0x80,0x72,0xC0,0x00,0x06,0x7C,0x00,
0x00,0xF3,0x15,0x15,0x19,0xC0,0x03,0x00,0x03,0x00,0x3E,0xC0,0x00,0x06,0x7C,0x00,
0x00,0xF3,0x0A,0x2A,0x90,0x3E,0x00,0xFF,0xFC,0x00,0x7C,0x81,0x40,0x06,0x7C,0x00,
0x00,0xF3,0x00,0x55,0x50,0x3D,0x00,0x00,0x00,0x00,0x7C,0x80,0xA0,0x06,0x7C,0x00,
0x00,0xF3,0x28,0xAA,0x90,0x1F,0x00,0x00,0x00,0x00,0x79,0xA9,0x40,0x06,0x7C,0x00,
0x00,0xF3,0x54,0x55,0x53,0x1C,0x1C,0x01,0x50,0x00,0x3D,0x50,0xA0,0x06,0x7C,0x00,
0x00,0xF3,0x28,0xAA,0x9C,0x08,0x03,0x82,0xA8,0x00,0x7F,0x28,0x00,0x06,0x7C,0x00,
0x00,0xF3,0x50,0x55,0x19,0x08,0x00,0x71,0x50,0x00,0x7A,0x50,0x00,0x06,0x7C,0x00,
0x00,0xF3,0x00,0xAA,0x2A,0x08,0x7C,0x0C,0x00,0x00,0x66,0x01,0x50,0x06,0x7C,0x00,
0x00,0xF3,0x00,0x54,0x4D,0x08,0x03,0x02,0x00,0x00,0x0C,0x02,0xA8,0x06,0x7C,0x00,
0x00,0xF3,0xFF,0x28,0x16,0x08,0x38,0xC1,0x00,0x00,0x18,0x85,0x55,0xFE,0x7C,0x00,
0x00,0xF1,0xFF,0x80,0x87,0x08,0x06,0x30,0x00,0x00,0x31,0x4A,0xA9,0xFC,0x7C,0x00,
0x00,0xF0,0x00,0x00,0x29,0xCC,0x01,0x08,0x80,0x00,0xE2,0x85,0x54,0x00,0x7C,0x00,
0x00,0xF0,0x00,0x00,0x00,0x7E,0x00,0x84,0x00,0x03,0x81,0x4A,0xA8,0x00,0x7C,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
//============================ LCM12864控制部分 ========================================
code uchar Chinese [][32]={
/*-- 文字: 趙 --*/
/*-- 楷體_GB231212; 此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16 --*/
0x00,0x00,0x04,0x00,0x04,0x10,0x07,0x10,0x1C,0x90,0x04,0x50,0x0F,0x20,0xF4,0x20,
0x07,0x50,0x24,0x88,0x35,0x08,0x4E,0x00,0x81,0xC0,0x00,0x3E,0x00,0x00,0x00,0x00,
/*-- 文字: 俊 --*/
/*-- 楷體_GB231212; 此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16 --*/
0x00,0x40,0x08,0x40,0x08,0x90,0x11,0x38,0x13,0xC8,0x30,0x20,0x51,0x18,0x92,0x88,
0x14,0xF0,0x11,0x10,0x12,0xA0,0x14,0x60,0x11,0x9E,0x10,0x00,0x00,0x00,0x00,0x00,
/*-- 文字: 設(shè) --*/
/*-- 楷體_GB231212; 此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16 --*/
0x00,0x00,0x20,0xE0,0x11,0x20,0x01,0x20,0x01,0x20,0x62,0x38,0xA4,0x00,0x21,0xE0,
0x22,0x20,0x21,0x40,0x28,0x80,0x31,0x40,0x22,0x30,0x0C,0x1E,0x00,0x00,0x00,0x00,
/*-- 文字: 計(jì) --*/
/*-- 楷體_GB231212; 此字體下對應(yīng)的點(diǎn)陣為:寬x高=16x16 --*/
0x00,0x40,0x10,0x40,0x08,0x40,0x00,0x40,0x00,0x40,0x30,0x7C,0xD3,0xC0,0x10,0x40,
0x10,0x40,0x14,0x40,0x18,0x40,0x10,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x00,
};
/*****************************************************
函 數(shù) 名:void LCM_ReadStatus(void)
功 能:讀忙狀態(tài)
說 明:判斷LCM的工作狀態(tài)字;也可以不用此函數(shù),用一段延時(shí)程序代替
入口參數(shù):無
返 回 值:無
*****************************************************/
void LCM_ReadStatus(void)
{
do
{
LCM_DATA = 0xFF; // LCM數(shù)據(jù)口先置1
LCM_CD = 1; // CD=1為指令通道,CD=0為數(shù)據(jù)通道
LCM_RD = 0; // 計(jì)算機(jī)對T6963C進(jìn)行讀操作
ACC=LCM_DATA;
LCM_RD = 1;
}while((ACC&0x03)!=0x03); // 低電平忙
}
/*****************************************************
函 數(shù) 名:void LCM_AutoWriteStatus(void)
功 能:數(shù)據(jù)自動(dòng)寫時(shí)LCM的狀態(tài)字
說 明:讓數(shù)據(jù)自動(dòng)讀寫時(shí),要判斷LCM是否忙
入口參數(shù):無
返 回 值:無
*****************************************************/
void LCM_AutoWriteStatus(void)
{
do
{
LCM_DATA = 0xFF; // LCM數(shù)據(jù)口先置1
LCM_CD = 1; // CD=1為指令通道,CD=0為數(shù)據(jù)通道
LCM_RD = 0; // 計(jì)算機(jī)對T6963C進(jìn)行讀操作
ACC=LCM_DATA;
LCM_RD = 1;
}while((ACC&0x08)!=0x08); // 低電平忙
}
/*****************************************************
函 數(shù) 名:void LCM_WriteData(uchar WDLCM)
功 能:向LCM12864中寫入數(shù)據(jù)
說 明:將形參WDLCM中的數(shù)據(jù)寫入LCM中
入口參數(shù):WDLCM
返 回 值:無
*****************************************************/
void LCM_WriteData(uchar WDLCM)
{
LCM_ReadStatus(); // 指令&數(shù)據(jù)讀寫狀態(tài)
LCM_CD = 0; // 通道選擇:允許寫入數(shù)據(jù)
LCM_DATA = WDLCM; // 寫入數(shù)據(jù)到LCM
LCM_WR = 0; // WR=0
LCM_WR = 1; // WR=1
}
/*****************************************************
函 數(shù) 名:void LCM_WriteCommand(uchar WCLCM)
功 能:向LCM12864中寫入無參指令
說 明:向LCM中寫入指令
入口參數(shù):WCLCM
返 回 值:無
*****************************************************/
void LCM_WriteCommand(uchar WCLCM)
{
LCM_ReadStatus();
LCM_DATA = WCLCM; // 寫入指令到LCM
LCM_CD = 1; // 通道選擇:允許寫入指令
LCM_WR = 0; // WR=0
LCM_WR = 1; // WR=1
}
/*****************************************************
函 數(shù) 名:void LCM_WriteCommand0ne(uchar WDATA,uchar WCLCM)
功 能:向LCM12864中寫入單參指令
說 明:向LCM中寫入指令
入口參數(shù):WCLCM
返 回 值:無
*****************************************************/
void LCM_WriteCommand0ne(uchar WDATA,uchar WCOM)
{
LCM_ReadStatus();
LCM_WriteData(WDATA);
LCM_ReadStatus();
LCM_WriteCommand(WCOM);
}
/*****************************************************
函 數(shù) 名:void LCM_WriteCommandTwo(uchar WD1,uchar WD2,uchar WCOMD)
功 能:向LCM12864中寫入雙參指令
說 明:向LCM中寫入指令
入口參數(shù):WCLCM
返 回 值:無
*****************************************************/
void LCM_WriteCommandTwo(uchar WD1,uchar WD2,uchar WCOMD)
{
LCM_ReadStatus();
LCM_WriteData(WD1);
LCM_ReadStatus();
LCM_WriteData(WD2);
LCM_ReadStatus();
LCM_WriteCommand(WCOMD);
}
/*****************************************************
函 數(shù) 名:void LCM_Init()
功 能:初始化LCM12864
說 明:LCM在工作前先要對顯示屏初始化,否則模塊無法正常工作
入口參數(shù):無
返 回 值:無
*****************************************************/
//LCM初始化
void LCM_Init(void)
{
LCM_WriteCommandTwo(0,0,0x40); // 設(shè)置文本顯示區(qū)首地址
LCM_WriteCommandTwo(0x10,0,0x41); // 設(shè)置文本顯示區(qū)寬度
LCM_WriteCommandTwo(0,0x08,0x42); // 設(shè)置圖形顯示區(qū)首地址0x0800
LCM_WriteCommandTwo(0x10,0,0x43); // 設(shè)置圖形顯示區(qū)寬度
LCM_WriteCommand(0xA7); // 設(shè)置光標(biāo)形狀 8x8方塊
LCM_WriteCommand(0x80); // 顯示方式設(shè)置:文本或圖形
LCM_WriteCommand(0x9c); // 顯示開關(guān)設(shè)置:文本開,圖形開,光標(biāo)閃爍關(guān)
}
/*****************************************************
函 數(shù) 名:void LCM_Clear(void)
功 能:清顯示存儲(chǔ)器函數(shù)
說 明:
入口參數(shù):無
返 回 值:無
*****************************************************/
void LCM_Clear(void)
{
uint i = 8192; // 此處僅清8K RAM,如果32K RAM都使用,請修改i=32768
LCM_WriteCommandTwo(0x00,0x00,0x24);
LCM_WriteCommand(0xB0); // 進(jìn)入自動(dòng)寫
while(i--)
{
LCM_AutoWriteStatus(); // 數(shù)據(jù)自動(dòng)寫狀態(tài)
LCM_WriteData(0x00); // 寫入數(shù)據(jù)
}
LCM_WriteCommand(0xB2); // 寫完后退出,退出自動(dòng)寫
}
/*****************************************************
函 數(shù) 名:void LCM_DisplayePicture(uchar arr[])
功 能:顯示圖片
說 明:在液晶模塊上顯示一幅圖片
入口參數(shù):arr[]為圖片
返 回 值:無
*****************************************************/
void LCM_DisplayePicture(uchar arr[])
{
uint i=0;
LCM_WriteCommandTwo(0,0x08,0x24); // 設(shè)置圖形顯示RAM地址
while(i<1024) // (128/8)*64
LCM_WriteCommand0ne(arr[i++],0xC0); // 寫入數(shù)據(jù)
}
/*****************************************************
函 數(shù) 名:void LCM_DisplayOneChar()
功 能:按指定坐標(biāo)中寫入數(shù)據(jù)
說 明:X-橫坐標(biāo),Y-縱坐標(biāo),DData為庫內(nèi)編碼值
入口參數(shù):x,y,DDATA
返 回 值:無
*****************************************************/
void LCM_DisplayOneChar(uchar x,uchar y,uchar DDATA)
{
uchar add;
add=y<<4|x; // 地址整合:y為高位地址,x為低位地址
LCM_WriteCommandTwo(add,0x00,0x24); // 寫入字符顯示地址
LCM_WriteCommand0ne(DDATA,0xC0); // 寫入數(shù)據(jù)
}
/*****************************************************
函 數(shù) 名:void LCM_DisplayListChar(uchar x,uchar y,uchar *arr)
功 能:顯示字符串
說 明:直接寫字符串時(shí),要減32;但寫入數(shù)組時(shí),就不用減
入口參數(shù):x,y,*arr
返 回 值:無
*****************************************************/
void LCM_DisplayListChar(uchar x,uchar y,uchar *arr)
{
uchar i,add,ListLength;
ListLength=strlen(arr); // 讀出字符串的長度
add=y<<4|x; // 地址整合:y為高位地址,x為低位地址
for(i=0;i
LCM_DisplayOneChar(x,y,arr[i]-0x20); // 寫入一個(gè)字符
x++; // 地址加1
}
}
/*****************************************************
函 數(shù) 名:void LCM_WriteChinese()
功 能:圖形方式下寫入漢字程序
說 明:每次寫入一個(gè)漢字
入口參數(shù):x,y,num,arr[][32]
返 回 值:無
*****************************************************/
void LCM_WriteChinese(uchar x,uchar y,uchar num,uchar arr[][32])
{
uchar i,j=0;
x *=2; // x每次以2增長
for(i=0;i<16;i++) // 循環(huán)寫入漢字字模
{
LCM_WriteCommandTwo(x,y+0x08,0x24); // 寫入漢字顯示地址
LCM_WriteCommand0ne(arr[num][j],0xC0); // 寫入漢字的左部字模
j++; // 取下一數(shù)據(jù)
LCM_WriteCommand0ne(arr[num][j],0xC0); // 寫入漢字的左部字模
j++; // 取下一數(shù)據(jù)
x +=16; // 下一行顯示
}
}
/*****************************************************
函 數(shù) 名:主函數(shù)
功 能:實(shí)現(xiàn)顯示
說 明:
入口參數(shù):無
返 回 值:無
*****************************************************/
void main()
{
LCM_Init(); // 初始化LCM
LCM_Clear(); // 清屏
LCM_DisplayePicture(CCTAB); // 寫入一幅圖
LCM_WriteChinese(2,0,0,Chinese); // 寫入"趙"
LCM_WriteChinese(3,0,1,Chinese); // 寫入"俊"
LCM_WriteChinese(4,0,2,Chinese); // 寫入"設(shè)"
LCM_WriteChinese(5,0,3,Chinese); // 寫入"計(jì)"
while(1);
}
/*============================= 程序結(jié)束 =============================================*/
二、匯編程序:
= = = = = = = = = =主程序= = = = = = = = = =
ORG 0000H
START : ORL P3,#1CH ?間接控制方式控制線初始化
LCALL INT ?調(diào)用初始化子程序
LCALL CLEAR ?調(diào)用清屏子程序
. . . . . . ?調(diào)用其他子程序
SJMP $
= = = = = = = T6963C 間接訪問通用子程序= = = = = =
一、間接控制方式驅(qū)動(dòng)子程序:
DAT1 EQU 30H ?第一參數(shù)單元
DAT2 EQU 31H ?第二參數(shù)單元
COM EQU 32H ?指令代碼單元
C_ADD EQU 8100H ?指令通道單元
D_ADD EQU 8000H ?數(shù)據(jù)通道單元
WR1 EQU P3.2 ?寫操作信號
RD1 EQU P3.3 ?讀操作信號
CD EQU P3.4 ?通道選擇信號
? _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
; 讀狀態(tài)字子程序
R_ST : ORL P3,#1CH ?間接控制方式控制線初始化
MOV P1,#0FFH ?P1 口置"1"
SETB CD ?CD=1
CLR RD ?RD=0
MOV A,P1 ?讀操作
SETB RD ?RD=1
RET
?;
判狀態(tài)位S1,S0 子程序(讀寫指令和讀寫數(shù)據(jù)狀態(tài))
ST01 : LCALL R_ST
JNB ACC.0,ST01 ?S0=1,順序執(zhí)行,否則循環(huán)
JNB ACC.1,ST01 ?S1=1,順序執(zhí)行,否則循環(huán)
RET
?;
判狀態(tài)位S2 子程序(數(shù)據(jù)自動(dòng)讀狀態(tài))
ST2 : LCALL R_ST
JNB ACC.2,ST2 ?S2=1,順序執(zhí)行,否則循環(huán)
RET
?;
判狀態(tài)位S3 子程序(數(shù)據(jù)自動(dòng)寫狀態(tài))
ST3 : LCALL R_ST
JNB ACC.3,ST3 ?S1=1,順序執(zhí)行,否則循環(huán)
RET
?;
判狀態(tài)位S6 子程序(屏讀/屏拷貝狀態(tài))
ST6 : LCALL R_ST
JNB ACC.6,ERR ?S6=1,順序執(zhí)行,錯(cuò)誤修正
RET
ERR : LJMP ST6 ?錯(cuò)誤修正
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
; 寫指令和寫數(shù)據(jù)子程序
PR1 : LCALL ST01 ?雙字節(jié)參數(shù)指令寫入入口
MOV A,DAT1 ?取第一參數(shù)單元數(shù)據(jù)
LCALL PR13 ?寫入?yún)?shù)
PR11 : LCALL ST01 ?單字節(jié)參數(shù)指令寫入入口
MOV A,DAT2 ?取第二參數(shù)單元數(shù)據(jù)
LCALL PR13 ?寫入?yún)?shù)
PR12 : LCALL ST01 ?無參數(shù)指令寫入入口
MOV A,COM ?取指令代碼單元數(shù)據(jù)
LJMP PR14 ?寫入指令代碼
PR13 : CLR CD ?C/D=0/數(shù)據(jù)寫入入口
PR14 : MOV P1,A ?設(shè)置數(shù)據(jù)
CLR WR1 ?WR=0
SETB WR1 ?WR=1
RET
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
; 讀數(shù)據(jù)子程序
PR2 : LCALL ST01 ?判斷狀態(tài)位
CLR CD ?C/D=0
MOV P1,#0FFH ?P1 口置"1"
CLR RD ?RD=0
MOV A,P1 ?讀取數(shù)據(jù)
SETB RD ?RD=1
MOV DAT2,A ?數(shù)據(jù)存入第二參數(shù)/數(shù)據(jù)單元
RET
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
二、初始化設(shè)置子程序
初始化設(shè)置主要是對顯示區(qū)域的設(shè)置和顯示方式的設(shè)置。此程序只需在主程序?qū)ο到y(tǒng)初始化時(shí)調(diào)用一
次就可以了,除非要在應(yīng)用中需要改變設(shè)置。其中在不同的顯示方式下,其最后的兩條指令不同,應(yīng)根據(jù)
需要改變其值。
INT : MOV DAT1,#00H ?設(shè)置文本顯示區(qū)域首地址
MOV DAT2,#00H
MOV COM,#40H
LCALL PR1
MOV DAT1,#10H ?設(shè)置文本顯示區(qū)域?qū)挾?br />MOV DAT2,#00H ?即一行顯示所占字節(jié)數(shù)
MOV COM,#41H
LCALL PR1
MOV DAT1,#00H ?數(shù)值圖形顯示區(qū)域首地址
MOV DAT2,#08H ?或?yàn)槲谋緦傩詤^(qū)域首地址
MOV COM,#42H
LCALL PR1
MOV DAT1,#10H ?數(shù)值圖形顯示區(qū)域?qū)挾?br />MOV DAT2,#00H ?或?yàn)槲谋緦傩詤^(qū)域?qū)挾?br />MOV COM,#43H ?即一行顯示所占字節(jié)數(shù)
LCALL PR1
MOV COM,#0A7H ?光標(biāo)形狀設(shè)置
LCALL PR12
MOV COM,#80H ?顯示方式設(shè)置邏輯"或"合成
LCALL PR12
MOV COM,#98H ?顯示開關(guān)設(shè)置開圖形顯示
LCALL PR12
RET
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
三、清顯示存儲(chǔ)器子程序
該子程序?qū)︼@示存儲(chǔ)器完全清零,不分顯示區(qū)域性質(zhì)。所以在初始化是使用和在全顯示存儲(chǔ)器需要清
零時(shí)使用。另外該程序也可以作為接口電路及驅(qū)動(dòng)程序的調(diào)試使用,將寫入的數(shù)據(jù)不為“0”,即可觀察顯
示效果。
CLEAR : MOV DAT1,#00H ?設(shè)置顯示存儲(chǔ)器首地址
MOV DAT2,#00H
MOV COM,#24H
LCALL PR1
MOV R3,#00H ?設(shè)置循環(huán)量
MOV R4,#20H
MOV COM,#0B0H ?設(shè)置自動(dòng)寫方式
LCALL PR12
CLEAR1 : LCALL ST3 ?判狀態(tài)為S2
MOV A,#00H ?置數(shù)據(jù)"0"
LCALL PR13 ?寫入數(shù)據(jù)
DJNZ R3,CLEAR1 ?循環(huán)
DJNZ R4,CLEAR1
MOV COM,#0B2H ?設(shè)置自動(dòng)寫結(jié)束指令
LCALL PR12
RET
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
四、文本方式漢字顯示子程序
該子程序是在內(nèi)部CGROM 有效時(shí)建立CGRAM 子程序的。所以使用的字符代碼是從80H 開始的。本
程序有兩中建立CGRAM 的子程序,其不同之處僅僅是因?yàn)椴捎貌煌淖帜L崛≤浖选6鴮τ跐h字寫
入子程序則是通用的。
文本方式漢字顯示演示
WBXS : MOV COUNT,#08H ?建立8 字節(jié)CGRAM(2 個(gè)漢字)
LCALL CGRAM ?建立CGRAM 子程序
MOV CODE1,#80H ?顯示"液"
MOV O_X,#03H
MOV O_Y,#02H
LCALL WRI_CT ?寫入漢字
MOV CODE1,#84H ?顯示"晶"
MOV O_X,#07H
MOV O_Y,#02H
LCALL WRI_CT ?寫入漢字
RET
漢字寫入子程序(文本方式)
O_Y EQU 34H ?Y 坐標(biāo)
O_X EQU 35H ?X 坐標(biāo)
COUNT EQU 36H ?計(jì)數(shù)器
WRI_CT : MOV A,O_Y ?計(jì)算顯示RAM 地址
MOV B,#10H
MUL AB
ADD A,O_X
MOV O_X,A
MOV DAT1,A
MOV A,B
ADDC A,#00H ?文本顯示區(qū)首地址為0000H
MOV O_Y,A
MOV DAT2,A ?設(shè)置顯示RAM 地址
MOV COM,#24H
LCALL PR1
MOV A,CODE1 ?取漢字代碼
MOV DAT2,A ?寫入左上半部漢字代碼
MOV COM,#0C0H
LCALL PR11
MOV A,CODE1
ADD A,#02H
MOV DAT2,A ?寫入右上半部漢字代碼
LCALL PR11
MOV A,#10H ?顯示RAM 地址修正
ADD A,O_X
MOV DAT1,A
CLR A
ADDC A,O_Y
MOV DAT2,A
MOV COM,#24H ?設(shè)置顯示RAM 地址
LCALL PR1
MOV A,CODE1
INC A
MOV DAT2,A ?寫入左下半部漢字代碼
MOV COM,#0C0H
LCALL PR11
MOV A,CODE1
ADD A,#03H
MOV DAT2,A ?寫入右下半部漢字代碼
LCALL PR11
RET
① 建立CGRAM 子程序
CODE1 EQU 33H ?漢字字符代碼
CGRAM : MOV DAT1,#03H ?設(shè)置CGRAM 偏置地址
MOV DAT2,#00H
MOV COM,#22H
LCALL PR1
MOV DAT1,#00H ?設(shè)置存儲(chǔ)器地址指針
MOV DAT2,#1CH
MOV COM,#24H
LCALL PR1
MOV COM,#0B0H ?設(shè)置自動(dòng)寫方式
LCALL PR12
MOV A,COUNT ?計(jì)算寫入的字節(jié)數(shù)
MOV B,#08H
MUL AB
MOV COUNT,A ?計(jì)算低8 位數(shù)據(jù)
INC B ?計(jì)算高8 位數(shù)據(jù)
MOV DPTR,#CGTAB ?取字符庫首地址
PUSH DPH ?存字符庫指針
PUSH DPL
CGRAM1 : LCALL ST3 ?判自動(dòng)寫狀態(tài)位
POP DPL ?取字符庫指針
POP DPH
CLR A
MOVC A,@A+DPTR ?取數(shù)據(jù)
INC DPTR ?字符庫指針加一
PUSH DPH ?存字符庫指針
PUSH DPL
LCALL PR13 ?寫入數(shù)據(jù)
DJNZ COUNT,CGRAM1 ?計(jì)數(shù)循環(huán)
DJNZ B,CGRAM1
MOV COM,#0B2H ?寫入結(jié)束自動(dòng)寫指令
LCALL PR12
POP ACC ?修正棧指針
POP ACC
RET
; 漢字庫
CGTAB : DB 00H,040H,37H,10H,081H,061H,22H,0AH ?"液"
DB 16H,02BH,0E2H,22H,22H,22H,023H,22H
DB 80H,044H,0FEH,20H,20H,03CH,44H,64H
DB 98H,048H,50H,20H,50H,08EH,004H,00H
DB 00FH,08H,08H,00FH,08H,08H,00FH,08H ?"晶"
DB 07EH,42H,42H,07EH,42H,42H,07EH,42H
DB 0E0H,20H,20H,0E0H,20H,20H,0E0H,24H
DB 0FEH,84H,84H,0FCH,84H,84H,0FCH,84H
? 用PICKHZB。EXE 提取字模
? 漢字字模排列格式為第1~16 字節(jié)為漢字左半部分自上而下排列的數(shù)據(jù),
? 第17~32 字節(jié)為漢字右半部分自上而下排列的字模數(shù)據(jù)。
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
?0117?
?0218?
. . . . . .
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
② 建立CGRAM 子程序
CODE1 EQU 33H ?漢字字符代碼
CGRAM : MOV DAT1,#03H ?設(shè)置CGRAM 偏置地址
MOV DAT2,#00H
MOV COM,#22H
LCALL PR1
;寫入左半部分字模
MOV R0,#00H ?計(jì)算存儲(chǔ)地址(奇數(shù)部分)
CGRAM0 : MOV A,R0
MOV B,#20H
MUL AB
MOV DAT1,A ?低位地址
MOV A,B
ADD A,#1CH
MOV DAT2,A ?高位地址
MOV COM,#24H ?設(shè)置存儲(chǔ)器地址指針
LCALL PR1
MOV COM,#0B0H ?設(shè)置自動(dòng)寫方式
LCALL PR12
MOV R1,#02H ?連續(xù)寫入字節(jié)數(shù)
MOV A,R1 ?計(jì)算寫入的字節(jié)數(shù)
MOV B,#08H
MUL AB
MOV R1,A ?計(jì)算低8 位數(shù)據(jù)
INC B ?計(jì)算高8 位數(shù)據(jù)
CJNE R0,#00H,CRAM0 ?從第二次起跳過符庫首地址讀取
MOV DPTR,#CGTAB ?取字符庫首地址
CRAM0 : PUSH DPH ?存字符庫指針
PUSH DPL
CGRAM1 : LCALL ST3 ?判自動(dòng)寫狀態(tài)位
POP DPL ?取字符庫指針
POP DPH
CLR A
MOVC A,@A+DPTR ?取數(shù)據(jù)
INC DPTR ?字符庫指針加一
INC DPTR
PUSH DPH ?存字符庫指針
PUSH DPL
LCALL PR13 ?寫入數(shù)據(jù)
DJNZ R1,CGRAM1 ?計(jì)數(shù)循環(huán)
DJNZ B,CGRAM1
MOV COM,#0B2H ?寫入結(jié)束自動(dòng)寫指令
LCALL PR12
POP ACC ?修正棧指針
POP ACC
INC R0 ?R0 加"1"
DJNZ COUNT,CGRAM0 ?判斷左半部分是否寫完
;寫入右半部分字模
MOV R0,#01H ?計(jì)算存儲(chǔ)地址(偶數(shù)部分)
CGRAM2 : MOV A,R0
MOV B,#10H
MUL AB
MOV DAT1,A ?低位地址
MOV A,B
ADD A,#1CH
MOV DAT2,A ?高位地址
MOV COM,#24H ?設(shè)置存儲(chǔ)器地址指針
LCALL PR1
MOV COM,#0B0H ?設(shè)置自動(dòng)寫方式
LCALL PR12
MOV R1,#02H ?連續(xù)寫入字節(jié)數(shù)
MOV A,R1 ?計(jì)算寫入的字節(jié)數(shù)
MOV B,#08H
MUL AB
MOV R1,A ?計(jì)算低8 位數(shù)據(jù)
INC B ?計(jì)算高8 位數(shù)據(jù)
CJNE R0,#01H,CRAM1 ?從第二次起跳過符庫首地址讀取
MOV DPTR,#CGTAB ?取字符庫首地址
INC DPTR
CRAM1 : PUSH DPH ?存字符庫指針
PUSH DPL
CGRAM3 : LCALL ST3 ?判自動(dòng)寫狀態(tài)位
POP DPL ?取字符庫指針
POP DPH
CLR A
MOVC A,@A+DPTR ?取數(shù)據(jù)
INC DPTR ?字符庫指針加一
INC DPTR
PUSH DPH ?存字符庫指針
PUSH DPL
LCALL PR13 ?寫入數(shù)據(jù)
DJNZ R1,CGRAM3 ?計(jì)數(shù)循環(huán)
DJNZ B,CGRAM3
MOV COM,#0B2H ?寫入結(jié)束自動(dòng)寫指令
LCALL PR12
POP ACC ?修正棧指針
POP ACC
INC R0 ?R0 加"2"
INC R0
DJNZ COUNT,CGRAM2 ?判斷右半部分是否寫完
RET
; 漢字庫
CGTAB : ?寵[16*16]橫排
DB 02h, 00h, 01h, 00h, 7Fh, 0FEh, 42h, 02h?代碼為80H
DB 82h, 84h, 02h, 50h, 3Fh, 0F8h, 02h, 80h
DB 02h, 90h, 04h, 0B0h, 04h, 0C0h, 08h, 80h
DB 09h, 82h, 12h, 82h, 20h, 7Eh, 40h, 00h
?辱[16*16]橫排
DB 00h, 10h, 3Fh, 0F8h, 20h, 00h, 2Fh, 0F0h?代碼為84H
DB 20h, 00h, 3Fh, 0FCh, 29h, 10h, 28h, 0A0h
DB 4Ah, 60h, 8Ch, 1Ch, 00h, 20h, 0FFh, 0FEh
DB 04h, 20h, 02h, 20h, 00h, 0A0h, 00h, 40h
建立CGRAM 的步驟:
1.在程序區(qū)內(nèi)建立漢字字模表CGTAB;
2.漢字代碼定義(以“寵”=80H 為例)
80H 漢字代碼(表示漢字左上半部字模代碼)
81H 隱含代碼(表示漢字左下半部字模代碼)
82H 隱含代碼(表示漢字右上半部字模代碼)
81H 隱含代碼(表示漢字右下半部字模代碼)
3.寫入N 漢字的字模數(shù)據(jù),設(shè)置COUNT 值為N*4
4.調(diào)用CGRAM 子程序
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
五、圖形方式文本顯示子程序
在圖形方式下顯示漢字是比較常用的方法。漢字字庫作在程序區(qū)內(nèi),按排定義各漢字的代碼。寫入漢
字字模如同寫入圖形數(shù)據(jù)一般,這里提供單字節(jié)漢字代碼使用的漢字寫入子程序。(即只有漢字,沒有屬性
的顯示子程序)
圖形方式文本演示程序
WBYS : MOV CODE1,#00H ?顯示”寵”
MOV O_X,#00H
MOV O_Y,#00H
LCALL WRI_CC ?文本寫入子程序
MOV CODE1,#01H ?顯示”辱”
MOV O_X,#02H
MOV O_Y,#00H
LCALL WRI_CC
RET
圖形方式下的寫入程序
CODE1 EQU 33H ?漢字字符代碼
O_Y EQU 35H ?Y 坐標(biāo)
O_X EQU 36H ?X 坐標(biāo)
COUNT EQU 34H ?計(jì)數(shù)器
WRI_CC : MOV A,O_Y ?計(jì)算圖形顯示RAM 地址
MOV B,#10H ?圖形顯示區(qū)寬度為20H
MUL AB
ADD A,O_X
MOV O_X,A
MOV A,B
ADDC A,#00H ?圖形顯示區(qū)首地址為0000H
MOV O_Y,A
MOV DPTR,#CCTAB ?計(jì)算漢字庫字符首地址
MOV A,CODE1
MOV B,#20H
MUL AB
ADD A,DPL
MOV DPL,A
MOV A,B
ADDC A,DPH
MOV DPH,A
PUSH DPH ?存字庫地址指針
PUSH DPL
MOV COUNT,#10H ?計(jì)數(shù)器設(shè)置為16 次
WRI_CC1 : MOV DAT1,O_X ?設(shè)置顯示RAM 地址
MOV DAT2,O_Y
MOV COM,#24H
LCALL PR1
POP DPL ?取字庫地址指針
POP DPH
CLR A
MOVC A,@A+DPTR ?取左部字模數(shù)據(jù)(奇數(shù)字模)
MOV DAT2,A ?設(shè)置數(shù)據(jù)
MOV A,#01H ?偏置地址為1
MOVC A,@A+DPTR ?取右部字模數(shù)據(jù)
MOV DAT1,A ?暫存數(shù)據(jù)
INC DPTR ?字庫地址指針加一
INC DPTR ?字庫地址指針加一
PUSH DPH ?存字庫地址指針
PUSH DPL
MOV COM,#0C0H ?設(shè)置一次寫數(shù)據(jù)指令代碼
LCALL PR11 ?寫入數(shù)據(jù)
MOV DAT2,DAT1 ?設(shè)置右部數(shù)據(jù)(偶數(shù)字模)
LCALL PR11 ?寫入數(shù)據(jù)
MOV A,#10H ?顯示RAM 地址修正
ADD A,O_X
MOV O_X,A
CLR A
ADDC A,O_Y
MOV O_Y,A
DJNZ COUNT,WRI_CC1 ?計(jì)數(shù)器循環(huán)
POP ACC ?修正棧指針
POP ACC
RET
; 漢字庫
CCTAB : ?寵[16*16]橫排
DB 02h, 00h, 01h, 00h, 7Fh, 0FEh, 42h, 02h?代碼為00H
DB 82h, 84h, 02h, 50h, 3Fh, 0F8h, 02h, 80h
DB 02h, 90h, 04h, 0B0h, 04h, 0C0h, 08h, 80h
DB 09h, 82h, 12h, 82h, 20h, 7Eh, 40h, 00h
?辱[16*16]橫排
DB 00h, 10h, 3Fh, 0F8h, 20h, 00h, 2Fh, 0F0h?代碼為01H
DB 20h, 00h, 3Fh, 0FCh, 29h, 10h, 28h, 0A0h
DB 4Ah, 60h, 8Ch, 1Ch, 00h, 20h, 0FFh, 0FEh
DB 04h, 20h, 02h, 20h, 00h, 0A0h, 00h, 40h
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
六、西文字符寫入子程序(文本屬性顯示方式的應(yīng)用)
非文本屬性顯示方式的西文字符寫入非常簡單,先設(shè)置顯示地址指針( 24H),再寫入字符代碼即可。
可以取WRI_C 程序的前15 條指令作為參考。
西文演示子程序
XWXS : MOV COM,#84H ?設(shè)置文本屬性顯示方式
LCALL PR12
MOV COM,#9FH ?開文本,圖形顯示及光標(biāo)閃爍顯示
LCALL PR12
MOV DAT1,#0EH ?光標(biāo)地址設(shè)置
MOV DAT2,#04H
MOV COM,#21H
LCALL PR1
LOOPA : MOV R2,#00H ?設(shè)置表間址寄存器=0
MOV R3,#00H ?設(shè)置顯示X 坐標(biāo)寄存器=0
MOV R4,#04H ?設(shè)置顯示Y 坐標(biāo)寄存器=1
LOOPB : MOV A,R2
MOV DPTR,#DTAB ?取代碼首地址
MOVC A,@A+DPTR
MOV CODE1,A ?置字符代碼
MOV ATTR,#05H ?設(shè)置負(fù)向顯示
MOV O_X,R3 ?置X 坐標(biāo)
MOV O_Y,R4 ?置Y 坐標(biāo)
LCALL WRI_C ?調(diào)子西文顯示程序
LCALL DELAY
MOV ATTR,#00H ?設(shè)置正向顯示
MOV O_X,R3 ?置X 坐標(biāo)
MOV O_Y,R4 ?置Y 坐標(biāo)
LCALL WRI_C ?調(diào)子西文顯示程序
LCALL DELAY
INC R2 ?表間址寄存器
INC R3 ?X 坐標(biāo)加1
MOV A,R2
CJNE A,#12,LOOPB ?寫入西文個(gè)數(shù)
LCALL DELAY
LJMP LOOPA
DELAY : MOV R5,#00H ?延時(shí)子程序
MOV R6,#00H
DELAY1: NOP
DJNZ R5,DELAY1
DJNZ R6,DELAY1
RET
西文顯示子程序
CODE1 EQU 33H ?漢字字符代碼
O_Y EQU 35H ?Y 坐標(biāo)
O_X EQU 36H ?X 坐標(biāo)
ATTR EQU 37H ?字符屬性碼(低4 位有效)
WRI_C : MOV A,O_Y ?計(jì)算文本顯示RAM 地址
MOV B,#10H ?文本顯示區(qū)寬度為10H
MUL AB
ADD A,O_X
MOV DAT1,A ?地址低8 位
MOV A,B
ADDC A,#00H
MOV DAT2,A ?地址高8 位
PUSH ACC ?存地址的高8 位
MOV COM,#24H ?設(shè)置地址指針
LCALL PR1
MOV DAT2,CODE1 ?寫入字符代碼
MOV COM,#0C4H
LCALL PR11
POP ACC
ADD A,#08H ?取地址的高8 位
MOV DAT2,A
MOV COM,#24H ?設(shè)置地址指針
LCALL PR1
MOV DAT2,ATTR ?寫入屬性參數(shù)
MOV COM,#0C4H
LCALL PR11
RET
字符庫
DTAB : DB 37H,45H,4CH,43H,4FH,4DH,45H
DB 00H,39H,4FH,55H,01H ?Welcom You!
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
七、繪點(diǎn)與消點(diǎn)子程序
利用T6963C 的位操作指令,可很簡單的設(shè)置點(diǎn)或清除點(diǎn)。這樣使作圖或作曲線簡單化了。程序的關(guān)
鍵點(diǎn)在于點(diǎn)地址的計(jì)算上。在演示程序中如是用的是置位指令則是用于置點(diǎn)。而用清零指令(即注釋指令)
則是用于清零。
繪點(diǎn)演示子程序
LOOP0 : MOV R2,#00H ?X 坐標(biāo)=0
MOV R3,#00H ?Y 坐標(biāo)=0
MOV R4,#50H ?循環(huán)量=80
LOOP1 : MOV A,R2
MOV O_X,A ?設(shè)置X 坐標(biāo)
MOV A,R3
SETB ACC.7 ?設(shè)置置點(diǎn)標(biāo)志位
? CLR ACC.7 ?設(shè)置消點(diǎn)標(biāo)志位
MOV O_Y,A ?設(shè)置Y 坐標(biāo)
LCALL WRI_D ?調(diào)繪點(diǎn)子程序
INC R2 ?X 坐標(biāo)加一
INC R3 ?Y 坐標(biāo)加一
DJNZ R4,LOOP1 ?循環(huán)
DEC R3 ?Y 坐標(biāo)減二
DEC R3
LOOP2 : MOV A,R2
MOV O_X,A
MOV A,R3
SETB ACC.7 ?設(shè)置置點(diǎn)標(biāo)志位
? CLR ACC.7 ?設(shè)置消點(diǎn)標(biāo)志位
MOV O_Y,A
LCALL WRI_D
INC R2 ?X 坐標(biāo)加一
DJNZ R3,LOOP2 ?循環(huán)
MOV R4,#50H ?循環(huán)量=80
LOOP3 : MOV A,R2
MOV O_X,A
MOV A,R3
SETB ACC.7 ?設(shè)置置點(diǎn)標(biāo)志位
? CLR ACC.7 ?設(shè)置消點(diǎn)標(biāo)志位
MOV O_Y,A
LCALL WRI_D
INC R2 ?X 坐標(biāo)加一
INC R3 ?Y 坐標(biāo)加一
DJNZ R4,LOOP3 ?循環(huán)
RET
繪點(diǎn)子程序
O_Y EQU 35H ?Y 坐標(biāo)(D7=1 置點(diǎn)? D7=0 清零)
O_X EQU 36H ?X 坐標(biāo)
WRI_D : MOV A,O_Y ?計(jì)算圖形顯示RAM 地址
CLR ACC.7
MOV B,#10H ?圖形顯示區(qū)寬度位10H
MUL AB
MOV DAT1,A
MOV DAT2,B
MOV A,O_X ?計(jì)算列地址
MOV B,#08H
DIV AB ?B 為點(diǎn)數(shù)值
ADD A,DAT1
MOV DAT1,A
MOV A,#08H ?圖形顯示區(qū)首地址為0800H
ADDC A,DAT2
MOV DAT2,A
MOV COM,#24H ?設(shè)置顯示RAM 地址
LCALL PR1
MOV A,B ?轉(zhuǎn)換位數(shù)據(jù)
CPL A
ANL A,#07H
XCH A,O_Y ?設(shè)置置/消點(diǎn)位
SWAP A
ANL A,#08H
ORL A,#0F0H ?設(shè)置位操作指令標(biāo)志
ORL A,O_Y ?設(shè)置操作位
MOV COM,A ?設(shè)置位操作指令
LCALL PR12
RET
評論