PCB光控打孔机第二版程序(一)

/*PCB机程序 XY同时启动 L9751 CODE61068 2018 6 19 08:00 固定位置释放吸盘*/
/*修正寻点第十二条结束调用计算坐标L5091,自动运行Y计算L6280 6281***/
/*** 开外部中断2关闭定时器2XY轴输出信号,自动运行循环检测外部中断高电平重启XY轴输出信号
增加寻点函数 手动赋值定时器0加减速计数器 程序编辑按START键运行起始动作 前进X电机不动
外中断复位 L6333 6396每块板占用300字节 添加外中断2 优化坐标数据显示***/
              #include       <reg52.h>
              #include       <intrins.h>
              #define        uchar    unsigned char
              #define        uint     unsigned int
              #define        ulong    unsigned long   //
              #define        EEPROM_START       310   //310字节开始存放XY值数据前300字节为当前动作存储数据
              #define        Ele_GearEEAdd    63000   //Z速度起始地址1234位置5678X电机位置9101112Y分子13141516Y分母 32字节
              #define        System_DataAdd   63033   //加速4 5 6 7 减速7 8 9 10 寻点11次数 增量12 12字节
              #define        Counter_DataAdd  63100   //计数器EEPROM起始地址  50条程序共50个字节
              #define        ProgNumber_Add   63155   //文件名保存EEPROM起始地址(高字节 低字节)X50=100字节
              #define        Number_Add       63260   //程序总数FRAM地址 1字节加    运行工号 1字节
              #define        FileName_Add     63300   //
              typedef        unsigned char BYTE;      //
              typedef        unsigned int WORD;
              sfr            INT_CLKO=0x8f;           //外部中断与时钟输出控制寄存器
              uchar          M_Speed,T_Speed;          //手动和编辑状态XY轴运动速度
              uchar          n1,n2;                      //显示缓冲
//uchar          Rst_Run;               //压脚中断定时器计数重启电机信号
              uint           aa,bb,a1,b1,a2;
              uint           Run_Data;                //
              uchar          Work_Counter;            //寻点失败计数器     走完寻点十二步计数器加一
              uchar          Prog_Num=0;              //文件名保存编号 计数器
              uchar          YSpeed;                  //Y轴电机速度
              uchar             Find_Counter;            //寻点标志计数器
              uchar          Find_data;               //寻点 次数
              long            AddVal;                  //寻点 增量
              uchar          Readya,Readyb;           //变量 备用1 备用2
              uchar          kcounter,kstatus;        //按键计数器 按键状态计数器
              uchar          ProgRead_Cursor;         //程序读入光标编号1-24
              uchar          EEY,EEZ;                 //EEPROM存储地址计算变量    EEY单件产品运行步数,EEZ工件编号
              uint           FileSave;                //文件名
              uint           Run_File;                //读出文件名名称
              uchar          Run_FileNum;             //读出运行文件名名称
              char           XCursor,YCursor;         //XY光标
              uint           Speed;                   //Z电机速度
              uint           Position;                //Z电机位置
              uint           XMtPParameter;           //X电机位置参数(上料动作)
              uint           YMtPParameter;           //Y电机位置参数(上料动作)    工件位置修正前进补偿
              uint           XMtSParameter;           //X电机速度参数(上料动作)
              uint           YMtSParameter;           //Y电机编辑前移停止
              uint           Down_Data;               //Z电机联动下降参数
              uint           Stop_Data;               //参数
              uint           XAddSpeed,YAddSpeed;     //Y电机加速
              uint           DecSpeed;                //Y电机减速
              uint           Up_Data;                 //电机上升缓冲
              uint           EditFun_Counter;         //程序编辑功能计数器     选择计数器 绝对运动 直线插补 测位跳转
              uchar          SysCursor;               //系统光标计数器
              uint           ProgSet_Counter;         //程序设置计数器
              uchar             Run_Counter;             //运行计数器
              uchar          Counter_Key;             //按键记录计数器
              uint           Prog_Number;             //程序编号
              uint           Frequency;               //频率
              uchar          Prog_LineNum;            //编程程序行号
              uint           RunLineNum;              //运行程序行号
              uchar          Speed_Data;              //速度百分比
              uint           Frequency;               //频率HZ
              sbit           EX_INT0=P3^2;            //PIN    29 外中断0
              sbit           EX_INT1=P3^3;            //PIN    30 外中断1
              sbit           EX_INT2=P3^6;            //PIN    35 外中断2
              sbit           EX_INT3=P3^7;            //PIN    36 外中断3
              sbit           cd=P7^7;                 //PIN    56
              sbit           ce=P4^5;                 //PIN    57
              sbit           rst=P4^6;                //PIN    58
              sbit           wr=P7^6;                 //PIN    55
              sbit           rd=P7^5;                 //PIN    54
              sbit           fs=P6^0;                 //PIN    5
              sbit           OUT1=P2^7;               //PIN    52    按键总线例
              sbit           OUT2=P7^4;               //PIN    53
              sbit           OUT3=P5^2;               //PIN    64
              sbit           OUT4=P5^3;               //PIN    1
              sbit           IN1=P2^4;                //PIN49    按键总线横
              sbit           IN2=P2^5;                //PIN50
              sbit           IN3=P2^6;                //PIN51
              sbit           IN4=P6^1;                //PIN6
              sbit           IN5=P6^2;                //PIN7
              sbit           IN6=P6^3;                //PIN8
              sbit           IN7=P5^5;                //PIN20
              sbit           INSERT=P3^2;               //停止  STOP
              sbit           STOP=P3^3;             //插入  INSERT
              sbit           CP1=P2^2;                //PIN47
              sbit           DIR1=P2^3;               //PIN48
              sbit           EN1=P7^2;                //PIN39
              sbit           CP2=P2^1;                //PIN46
              sbit           DIR2=P7^1;               //PIN38
              sbit           EN2=P7^0;                //PIN37
              sbit           CP3=P3^5;                //PIN34  P3^5;
              sbit           DIR3=P5^1;               //PIN33  P5^1;
              sbit           EN3=P4^0;                //PIN22  P4^0;
              sbit           INTPUT0=P2^0;            //PIN45
              sbit           INTPUT1=P4^4;            //PIN44
              sbit           INTPUT2=P4^3;            //PIN43
              sbit           INTPUT3=P4^2;            //PIN42
              sbit           INTPUT4=P4^1;            //PIN41
              sbit           INTPUT5=P7^3;            //PIN40
              sbit           INTPUT6=P3^7;            //PIN36
              sbit           INTPUT7=P3^6;            //PIN35
              sbit           OUTPUT0=P1^0;            //PIN9吸盘
              sbit           OUTPUT1=P1^1;            //PIN10夹具
              sbit           GREEN=P4^7;              //PIN11
              sbit           RED=P1^2;                //PIN12
              sbit           BUZZ=P6^6;               //PIN25
              sbit           OUTPUT5=P6^5;            //PIN24  6.5 1.1
              //sbit           OUTPUT6=P6^6;          //PIN25
              sbit           SCL=P1^7;                //PIN17 外部EEPROM       24C64PIN6  外部引脚设置开漏
              sbit           SDA=P5^4;                //PIN18 外部EEPROM       24C64PIN5
              uint           i,j,k,l,m,n;             //显示存储缓冲
              uint           Key_val;                 //按键值个位存储缓冲
              ulong          B_Data;                  //个位
              ulong          T_Data;                  //十位
              ulong          H_Data;                  //百位
              ulong          K_Data;                  //千位
              ulong          TK_Data;                 //万位
              ulong          M_Data;                  //十万位
              ulong          Chuang_Buff;             //转换缓冲
              ulong          XMemory,YMemory;         //临时缓冲数据
              bit            ManuSet_Flag;            //手动设定运行标志
              bit            ManuFast_Flag;           //手动高速反显标志
              bit            JogOperating_Flag;       //点动操作反显标志
              bit            JogOperatSet_Flag;       //点动操作设定标志
              bit            ProgAdmin_Flag;          //程序管理循环检测标志
              bit            ProgEdit_Flag;           //程序编辑循环检测标志
              bit            ProgRead_Flag;           //程序读入循环检测标志
              bit            ProgSave_Flag;           //程序保存循环检测标志
              bit            ProgSaveas_Flag;         //程序另存循环检测标志
              bit            DataSet_Flag;            //参数设置循环检测标志
              bit            SystemDataSet_Flag;      //系统参数设置循环检测标志
              bit            SystemSeifTest_Flag;     //系统自检循环检测标志
              bit            SystemSet_Flag;          //系统数据设置循环检测标志   分子分母最高时间点位起速
              bit            IOSet_Flag;              //IO设置循环检测标志
              bit            XPosiNegate_Flag;        //X值正负标志
              bit            YPosiNegate_Flag;        //Y值正负标志
              bit            AUTO_FLAG;               //自动运行标志
              bit            MOTARUN_FLAG;            //定时器电机A运行标志
              bit            MOTBRUN_FLAG;            //定时器电机B运行标志
              bit            ManuMTARUN_FLAG;         //手动定时器电机A运行标志
              bit            ManuMTBRUN_FLAG;         //手动定时器电机B运行标志
              bit            Factor_FLAG;             //厂值循环运行标志
              bit            X_AddDecFlag;            //手动左移右移加减标志
              bit            Y_AddDecFlag;            //手动前进后退加减标志
              bit            RUN;                     //启动定时器运行标志 任意一定时器启动开RUN,两定时器结束关RUN
              bit            Page_Flag;               //系统数据设置换页循环标志
              bit            Page2Read_Flag;          //程序读出第二页循环标志
              bit            Stop_Flag;               //自动运行停机段循环标志
              bit            Down_Flag;               //XY轴启动Z轴联动循环标志,运行完下降距离标志位置零
              bit            AUTO_STOPFLAG;           //自动暂停运行标志
              bit            PressFoot_Flag;           //压脚中断信号  外部压脚中断 置一 定时器2和外部打孔中断复位
              bit            PastShooting_Flag;       //
              bit            INT1_Flag;               //外中断1标志,自动暂停,返回检测START,ESC退出主程序。
              uint           DownData;                //下降距离    缓冲器
              #define        dataport P0              //P0为LCD数据口
              uchar          counter;                 //按键计数器
              ulong          D_Data;                  //点动输入值
              ulong          Buff_Data;               //缓冲处理变量
              ulong          XBuff_Data;              //X缓冲处理变量
              ulong          YBuff_Data;              //Y缓冲处理变量
              long           FindData;                //寻点运行值
              long           X_FData,Y_FData;         //XY寻点运算结果
              long           X_Data,Y_Data;           //XY当前值
              long           X_RunData,Y_RunData;     //XY定时器运行值
              long           XRun_Data;               //X设定值
              long           YRun_Data;               //Y设定值
              long           DRun_Data;               //点动运行值
              long           vala,valb;               //实际位置与设定位置差,
              sbit           Rom_CS=P1^4;             /*1字库IC接口定义Rom_CS就是字库IC的CS#*/
              sbit           Rom_SCK=P1^6;            /*2字库IC接口定义:Rom_SCK就是字库IC的SCK*/
              sbit           Rom_OUT=P1^3;            /*字库IC接口定义:Rom_OUT就是字库IC的OUT*/
              sbit           Rom_IN=P1^5;             /*字库IC接口定义:Rom_IN就是字库IC的IN*/
              uchar          fontbuff[32];            //字库中读出的32位数据存放缓冲数组单元
              uchar          newbuff[32];             //字库中读出的32位数据转换缓冲存储
              bdata          char com_data;           /********/
              sbit           mos_bit=com_data^7;      /****高位****/
              sbit           low_bit=com_data^0;      /****低位****/
              void           display_manufast(void);
              void           jog_operating(void);
              void           Dis_ZMtSpeed(void);      //正显Z电机速度参数
              void           Dis_ZMtPosition(void);   //正显Z电机位置参数  
              void           Dis_XMtPosition(void);   //正显X电机位置参数  
              void           Dis_XMtPParameter(void); //正显X电机位置参数  
              void           Dis_YMtPParameter(void); //显示Y电机位置参数
              void           Dis_YMT_Speed(void);     //显示Y电机速度参数
              void           Dis_SParameter(void);    //显示起速参数
              void           Dis_ZMTDown(uint);       //
              void           Dis_XMTStop(void);       //X电机停止参数
              void           Negate_XMTStop(void);    //反显X电机停止参数
              void           Negate_ZMtSpeed(void);   //反显Z电机速度参数
              void           Negate_ZMtPosition(void);//反显Z电机位置参数
              void           Negate_XMtPParameter(void);//反显X电机位置参数
              void           Negate_YMtPParameter(void);//反显Y电机位置参数
              void           Negate_HParameter(void); //最高参数闪烁
              void           Negate_SParameter(void); //起速参数闪烁
              void           Negate_ZMTDown(void);    //参数闪烁
              void           Change_FourData(uint ss); //四位数转换个十百千
              void           Display_c(void);           //程序编辑计数器界面显示
              void           NegateDis_Factor_Value(void); //
              void           NegateDis_System(void);       //
              void           Dis_X_AddSpeed(void);         //
              void           Negate_X_AddSpeed(void);      //
              void           Dis_Y_AddSpeed(void);         //
              void           Negate_Y_AddSpeed(void);      //
              void           Dis_Find_Data(void);          //
              void           Negate_Find_Data(void);       //
              void           Dis_Add_Data(void);           //
              void           Negate_Add_Data(void);        //
              void           display_manusmart(void);      //
              void           RstKey(void);                 //按键计数器状态寄存器归零
              void           LowVoltKey(void);             //按键低电平检测
              void           HighVoltKey(void);            //按键高电平检测
              void           DisFileName(uchar X1,Y1);       //
              void           Dis_Counter(void);               //
              void           ReadCounter_Data(void);       //
              void           TestK2(void);                   //
              uchar          ReadRunCounter_Data(uchar m); //
              uint           ReadProg_Name(uchar s);
              uchar          code Clearbuff[32]={
              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
              };
              int      code fontadd[32]={0,8,1,9,2,10,3,11,          //竖置横排转横置横排点阵排列表
                           4,12,5,13,6,14,7,15,
                           16,24,17,25,18,26,19,27,
                           20,28,21,29,22,30,23,31};
int      code xsadd[38]={0,16,32,48,64,80,96,112,128,144,160,176,192,208,224,240,256,272,288,304, //0-9清除XY.TPF%
      320,336,352,368,384,400,416,432,448,464,480,496,512,528,544,560,576,592};//0-9首地址 每字16字节
uchar code tab0[618]={
0X00,0X3C,0X42,0X42,0X42,0X42,0X42,0X42,
0X42,0X42,0X42,0X42,0X42,0X42,0X3C,0X00,//0
0X00,0X30,0X50,0X10,0X10,0X10,0X10,0X10,
0X10,0X10,0X10,0X10,0X10,0X10,0X38,0X00,//1
0X00,0X3C,0X42,0X02,0X02,0X02,0X04,0X08,
0X10,0X20,0X20,0X40,0X40,0X42,0X7E,0X00,//2
0X00,0X3C,0X42,0X02,0X02,0X02,0X02,0X3C,
0X02,0X02,0X02,0X02,0X02,0X42,0X3C,0X00,//3
0X00,0X0C,0X14,0X24,0X24,0X44,0X44,0X84,
0X84,0XFE,0X04,0X04,0X04,0X04,0X04,0X00,//4
0X00,0X7E,0X40,0X40,0X40,0X40,0X7C,0X02,
0X02,0X02,0X02,0X02,0X42,0X42,0X3C,0X00,//5
0X00,0X3C,0X42,0X40,0X40,0X40,0X7C,0X42,
0X42,0X42,0X42,0X42,0X42,0X42,0X3C,0X00,//6
0X00,0X3E,0X42,0X04,0X04,0X08,0X08,0X10,
0X10,0X10,0X10,0X10,0X10,0X10,0X10,0X00,//7
0X00,0X3C,0X42,0X42,0X42,0X42,0X42,0X3C,
0X42,0X42,0X42,0X42,0X42,0X42,0X3C,0X00,//8
0X00,0X3C,0X42,0X42,0X42,0X42,0X42,0X3C,
0X02,0X02,0X02,0X02,0X02,0X42,0X3C,0X00,//9
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//"清除"
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*10,*/    
0X00,0X00,0X42,0X42,0X24,0X24,0X18,0X18,//X
0X18,0X18,0X24,0X24,0X42,0X42,0X00,0X00,//11
0X00,0X00,0X41,0X41,0X22,0X14,0X08,0X08,//Y
0X08,0X08,0X08,0X08,0X08,0X08,0X00,0X00,//12
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,// .    
0X00,0X00,0X00,0X00,0X00,0X60,0X60,0X00,//13
0X00,0X3C,0X42,0X42,0X40,0X40,0X40,0X3C,//S
0X02,0X02,0X02,0X02,0X42,0X42,0X3C,0X00,//14    
0X00,0X7F,0X08,0X08,0X08,0X08,0X08,0X08,//T      
0X08,0X08,0X08,0X08,0X08,0X08,0X08,0X08,//15
0X00,0X7C,0X42,0X42,0X42,0X42,0X7C,0X40,//P       
0X40,0X40,0X40,0X40,0X40,0X40,0X40,0X00,//16
0X00,0X7E,0X40,0X40,0X40,0X40,0X7C,0X40,//F       
0X40,0X40,0X40,0X40,0X40,0X40,0X40,0X00,//17
0X00,0X22,0X52,0X52,0X24,0X04,0X08,0X08,//%       
0X10,0X10,0X20,0X24,0X4A,0X4A,0X44,0X00,//18
0X00,0X42,0X42,0X62,0X62,0X52,0X52,0X4A,//N       
0X4A,0X46,0X46,0X42,0X42,0X42,0X42,0X00,//19
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,//填充
0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF, //    20
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//清除光标
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//21
0X00,0X40,0X40,0X40,0X40,0X40,0X40,0X40,//L
0X40,0X40,0X40,0X40,0X40,0X40,0X7E,0X00,//22
0X00,0X00,0X00,0X00,0X00,0X5C,0X62,0X42,//n
0X42,0X42,0X42,0X42,0X42,0X42,0X42,0X00,//23
0X00,0X1C,0X08,0X08,0X08,0X08,0X08,0X08,//I
0X08,0X08,0X08,0X08,0X08,0X08,0X1C,0X08,//24
0X00,0X02,0X02,0X02,0X04,0X04,0X08,0X08,//斜杠/
0X10,0X10,0X20,0X20,0X40,0X40,0X40,0X00,//25
0X00,0X7F,0X7F,0X60,0X60,0X60,0X60,0X60,//方框左部
0X60,0X60,0X60,0X60,0X60,0X7F,0X7F,0X00,//26
0X00,0XFE,0XFE,0X06,0X06,0X06,0X06,0X06,//方框右部
0X06,0X06,0X06,0X06,0X06,0XFE,0XFE,0X00,//27
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//:分号
0X00,0X00,0X60,0X60,0X00,0X60,0X60,0X00,//28
0X00,0X7F,0X7F,0X60,0X6F,0X6F,0X6F,0X6F,//方框加点左部
0X6F,0X6F,0X6F,0X6F,0X00,0X7F,0X7F,0X00,//29
0X00,0XFE,0XFE,0X06,0XF6,0XF6,0XF6,0XF6,//方框加点右部
0XF6,0XF6,0XF6,0XF6,0X06,0XFE,0XFE,0X00,//30
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X3F,//-左部
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//31
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XFC,//-右部
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//32
0X00,0X00,0X07,0X08,0X10,0X20,0X20,0X20,//空心圆左部
0X20,0X20,0X20,0X10,0X08,0X07,0X00,0X00,//33
0X00,0X00,0XE0,0X10,0X08,0X04,0X04,0X04,//空心圆右部
0X04,0X04,0X04,0X08,0X10,0XE0,0X00,0X00,//34
0X00,0X00,0X07,0X0F,0X1F,0X3F,0X3F,0X3F,//实心圆左部
0X3F,0X3F,0X3F,0X1F,0X0F,0X07,0X00,0X00,//35
0X00,0X00,0XE0,0XF0,0XF8,0XFC,0XFC,0XFC,//实心圆右部
0XFC,0XFC,0XFC,0XF8,0XF0,0XE0,0X00,0X00,//36
0X00,0X00,0X00,0X00,0X00,0X49,0X2A,0X1C,//*
0X08,0X1C,0X2A,0X49,0X00,0X00,0X00,0X00//37
};
uchar code tab1[32]={
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XFF,//-
0XFF,0X00,0X00,0X00,0X00,0X00,0X00,0X00,//0
0X00,0X00,0X7E,0X42,0X04,0X04,0X08,0X08,//Z
0X10,0X10,0X20,0X20,0X42,0X7E,0X00,0X00 //1
};
/*------------延时子程序---------------------*/
              void delay(unsigned int t)
              {  
              unsigned int i;
              for(i=0;i<t;i++)
              {}
              }
/**************************************/
               void start()
               {
               SDA=1;
               SCL=1;
               SDA=0;
               SCL=0;
               }
/***************************************/
               void stop()
               {
               SDA=0;
               SCL=1;
               SDA=1;
               }
/***************************************/
               void ack()
               {
               SCL=1;
               SCL=0;
               }
/***************************************/
               void shift8(char a)
               {
               data uchar i;
               com_data=a;
                for(i=0;i<8;i++)
                {
                SDA=mos_bit;
                SCL=1;
                SCL=0;
                com_data=com_data*2;
                }
               }
/***************************************/
               uchar rd_24C64(uint a)
               {
               uint addh,addl;
               data uint i,command;
               addl=a;
               addh=a>>8;
               SDA=1;
               SCL=0;
               start();
               command=160;
               shift8(command);                            /*****写入160*****/
               ack();                                        
               shift8(addh);                               /*****写高八位地址addh 高三位无效*****/
               ack();
               shift8(addl);                               /*****写入低八位地址 addl*****/
               ack();
               start();
               command=161;
               shift8(command);                            /*****写入161*****/
               ack();
               SDA=1;
               for(i=0;i<8;i++)
                {
                 com_data=com_data*2;
                 SCL=1;
                 low_bit=SDA;
                 SCL=0;
                }
               stop();
               return(com_data);
              }
/***************************************/
               void wr_24C64(uint a,char b)      //a地址 b数据
               {
               uint addh,addl;
               data uint command;
               addl=a;
               addh=a>>8;
               _nop_();
               SDA=1;
               SCL=0;
               start();
               command=160;
               shift8(command);                            /*****写入160*****/
               ack();                                        
               shift8(addh);                               /*****写高八位地址addh 高三位无效*****/
               ack();
               shift8(addl);                               /*****写入低八位地址 addl*****/
               ack();
               shift8(b);                                  /*****写入 b *****/
               ack();
               stop();
               _nop_();
               }
/************延时函数****************/
              void delay_nms(unsigned int n)
              {
              unsigned int i,j;
              for(i=n;i>0;i--)
              {
               for(j=2000;j>0;j--)
               {
               }
              }
              }
/***状态检查函数*指令,数据读写状态检查**/
              void Lcd_Busy()
              {
              uchar dat;
               do
               {
               dataport=0xff;
               ce=0;  
               cd=1;  
               wr=1;  
               rd=0;  
               dat=dataport;
               rd=1;    
               dat=0x03&dat;//STA0,STA1是否准备好
              }
              while(dat!=0x03);
              }
/*******数据自动写状态检查*****************/
              void autowcheck()
              {
              uchar dat;
               do
               {
               dataport=0xff;
               ce=0;    
               cd=1;    
               wr=1;    
               rd=0;    
               dat=dataport;
               rd=1;    
               dat=0x08&dat;//STA3是否准备好
              }
              while(dat==0x00);
              }
/*------输入/出函数,与T6963通讯------------------------------------------------*/
// 向数据口发Data
              void wr_data(uchar dat)
              {  
              ce=0;
              cd=0;      nop_();_nop_();_nop_();
              dataport=dat;
              wr=0;          
              wr=1;           
              }
/*****写有1个参数命令***********/
              void wr_com1(uchar command)
              {
              Lcd_Busy();
              cd=1;        
              ce=0;    
              rd=1;        
              dataport=command;
              wr=0;        
              wr=1;        
              }
/******写有 3 个参数命令*******************/
              void wr_com3(uchar data1, uchar data2, uchar command)
              {
              Lcd_Busy();
              wr_data(data1);
              Lcd_Busy();
              wr_data(data2);    
              wr_com1(command);
              }
/*--------------------------------*/
              void lcd_address(uchar urow,uchar ucol)    //urow 为1---30(240/8=30),,ucol为1---64
              {
              uint ipos;
              uchar urow1;
              uchar ucol1;
              urow1=urow-1;     //    1---30
              ucol1=ucol-1;     //    1---64
              ipos=ucol1*30+urow1;
              wr_com3(ipos&0xff,0x08+ipos/256,0x24);
              }   L0496

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值