本帖最后由 34af9uc 于 2021-8-24 22:53 编辑
/***************SC92F7323+LCD88888*****************/
/***************QQ:74145445************************/
/*************快手:共同学习STM8********************/
/*************keiluvision2*************************/
/*************20210808*****************************/
/**************************************************/
// lcd88888
//|1|2|3|4|5|6|7|8|9|10|11|12|com4|com3|com2|com1|
/**************************************************/
//SC92F7323 ________ ________
// 5V-|1 /VDD \_/ P0.0/28|-com1
// 0V-|2 /VSS P0.1/27|-com2
// -|3 /P5.1 P0.2/26|-com3
// -|4 /P5.0 P0.3/25|-com4
// -|5 /P1.0 P0.4/24|-lcd_1
// -|6 /P1.1 P0.5/23|-lcd_2
// TCK-|7 /P1.2 P0.6/22|-lcd_3
// TDIO-|8 /P1.3 P0.7/21|-lcd_4
// -|9 /P1.4 P2.0/20|-lcd_5
// -|10/P1.5 P2.1/19|-lcd_6
// -|11/P1.6 P2.2/18|-lcd_7
// beiguang-|12/P1.7 P2.3/17|-lcd_8
// lcd_12-|13/P2.7 P2.4/16|-lcd_9
// lcd_11-|14/P2.6______P2.5/15|-lcd_10
/**************************************************/
#include <SC92F732x_C.H>
/**************************************************/ //lcd
sbit lcd_1 =P0^4;
sbit lcd_2 =P0^5;
sbit lcd_3 =P0^6;
sbit lcd_4 =P0^7;
sbit lcd_5 =P2^0;
sbit lcd_6 =P2^1;
sbit lcd_7 =P2^2;
sbit lcd_8 =P2^3;
sbit lcd_9 =P2^4;
sbit lcd_10 =P2^5;
sbit lcd_11 =P2^6;
sbit lcd_12 =P2^7;
sbit beiguang =P1^7;
unsigned char lcd_a1; //第一位
unsigned char lcd_a2; //第二位
unsigned char lcd_a3; //第三位
unsigned char lcd_a4; //第四位
unsigned char lcd_a5; //第五位
unsigned char xs_a1; //显示用
unsigned char xs_a2;
unsigned int xs_a3;
unsigned char code biao[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //0-9字模
/**************************************************/
#define bit0 0x01
#define bit1 0x02
#define bit2 0x04
#define bit3 0x08
#define bit4 0x10
#define bit5 0x20
#define bit6 0x40
#define bit7 0x80
#define com1_gao P0VO &= ~bit0; P00=1
#define com1_ban P0VO |=bit0
#define com1_di P0VO &= ~bit0; P00=0
#define com2_gao P0VO &= ~bit1; P01=1
#define com2_ban P0VO |=bit1
#define com2_di P0VO &= ~bit1; P01=0
#define com3_gao P0VO &= ~bit2; P02=1
#define com3_ban P0VO |=bit2
#define com3_di P0VO &= ~bit2; P02=0
#define com4_gao P0VO &= ~bit3; P03=1
#define com4_ban P0VO |=bit3
#define com4_di P0VO &= ~bit3; P03=0
/**************************************************/
void lcd_xianshi(); //lcd显示
void jisuan(); //计算
void yanshi(); //延时
/**************************************************/
void main()
{
//unsigned char a1;
/**************************************************/
xs_a1 =0;
xs_a2 =0;
xs_a3 =0;
/**************************************************/ //液晶初始化
P0CON |=bit0|bit1|bit2|bit3|bit4|bit5|bit6|bit7; //输出模式
P2CON |=bit0|bit1|bit2|bit3|bit4|bit5|bit6|bit7;
OTCON =bit3|bit2; //分压电阻87.5k
P1CON |=bit7; //背光输出
/**************************************************/
jisuan();
while(1)
{
xs_a1 ++;
// {
if(xs_a1>9) {xs_a1 =0;}
xs_a2 ++;
jisuan();
if(xs_a2>9)
{
xs_a2 =0;
xs_a3 ++;
if(xs_a3>9999) {xs_a3=0;}
}
// }
lcd_xianshi();
}
}
void lcd_xianshi() //lcd显示
{
/**************************************************/ //lcd正控
com1_ban;
com2_ban;
com3_ban;
com4_ban;
if(lcd_a1 & bit5) {lcd_1 =0;} else{lcd_1 =1;} //1f
if(lcd_a1 & bit0) {lcd_2 =0;} else{lcd_2 =1;} //1a
if(lcd_a2 & bit5) {lcd_3 =0;} else{lcd_3 =1;} //2f
if(lcd_a2 & bit0) {lcd_4 =0;} else{lcd_4 =1;} //2a
//if(lcd_xianshi) {lcd_5 =0;} else{lcd_5 =1;} //02竖
lcd_5 =0;
if(lcd_a3 & bit5) {lcd_6 =0;} else{lcd_6 =1;} //3f
if(lcd_a3 & bit0) {lcd_7 =0;} else{lcd_7 =1;} //3a
if(lcd_a4 & bit5) {lcd_8 =0;} else{lcd_8 =1;} //4f
if(lcd_a4 & bit0) {lcd_9 =0;} else{lcd_9 =1;} //4a
if(lcd_a5 & bit5) {lcd_10 =0;} else{lcd_10 =1;} //5f
if(lcd_a5 & bit0) {lcd_11 =0;} else{lcd_11 =1;} //5a
//if(lcd_a) {lcd_12 =0;} else{lcd_12 =1;} //01锁定
lcd_12 =1;
com1_gao; //com1高
com2_ban;
com3_ban;
com4_ban;
yanshi();
com1_ban;
com2_ban;
com3_ban;
com4_ban;
if(lcd_a1 & bit6) {lcd_1 =0;} else{lcd_1 =1;} //1g
if(lcd_a1 & bit1) {lcd_2 =0;} else{lcd_2 =1;} //1b
if(lcd_a2 & bit6) {lcd_3 =0;} else{lcd_3 =1;} //2g
if(lcd_a2 & bit1) {lcd_4 =0;} else{lcd_4 =1;} //2b
//if(lcd_a) {lcd_5 =0;} else{lcd_5 =1;} //防冻
lcd_5 =1;
if(lcd_a3 & bit6) {lcd_6 =0;} else{lcd_6 =1;} //3g
if(lcd_a3 & bit1) {lcd_7 =0;} else{lcd_7 =1;} //3b
if(lcd_a4 & bit6) {lcd_8 =0;} else{lcd_8 =1;} //4g
if(lcd_a4 & bit1) {lcd_9 =0;} else{lcd_9 =1;} //4b
if(lcd_a5 & bit6) {lcd_10 =0;} else{lcd_10 =1;} //5g
if(lcd_a5 & bit1) {lcd_11 =0;} else{lcd_11 =1;} //5b
//if(lcd_a) {lcd_12 =0;} else{lcd_12 =1;} //中
lcd_12 =1;
com1_ban;
com2_gao; //com2高
com3_ban;
com4_ban;
yanshi();
com1_ban;
com2_ban;
com3_ban;
com4_ban;
if(lcd_a1 & bit4) {lcd_1 =0;} else{lcd_1 =1;} //1e
if(lcd_a1 & bit2) {lcd_2 =0;} else{lcd_2 =1;} //1c
if(lcd_a2 & bit4) {lcd_3 =0;} else{lcd_3 =1;} //2e
if(lcd_a2 & bit2) {lcd_4 =0;} else{lcd_4 =1;} //2c
//if(lcd_a) {lcd_5 =0;} else{lcd_5 =1;} //保护
lcd_5 =1;
if(lcd_a3 & bit4) {lcd_6 =0;} else{lcd_6 =1;} //3e
if(lcd_a3 & bit2) {lcd_7 =0;} else{lcd_7 =1;} //3c
if(lcd_a4 & bit4) {lcd_8 =0;} else{lcd_8 =1;} //4e
if(lcd_a4 & bit2) {lcd_9 =0;} else{lcd_9 =1;} //4c
if(lcd_a5 & bit4) {lcd_10 =0;} else{lcd_10 =1;} //5e
if(lcd_a5 & bit2) {lcd_11 =0;} else{lcd_11 =1;} //5c
//if(lcd_a) {lcd_12 =0;} else{lcd_12 =1;} //加热
lcd_12 =1;
com1_ban;
com2_ban;
com3_gao; //com3高
com4_ban;
yanshi();
com1_ban;
com2_ban;
com3_ban;
com4_ban;
//if(lcd_a) {lcd_1 =0;} else{lcd_1 =1;} //室温
lcd_1 =1;
if(lcd_a1 & bit3) {lcd_2 =0;} else{lcd_2 =1;} //1d
//if(lcd_a) {lcd_3 =0;} else{lcd_3 =1;} //设定摄氏度(显示)
lcd_3 =0;
if(lcd_a2 & bit3) {lcd_4 =0;} else{lcd_4 =1;} //2d
//if(lcd_a){lcd_5 =0;} else{lcd_5 =1;} //空
lcd_5 =1;
//if(lcd_a) {lcd_6 =0;} else{lcd_6 =1;} //地温
lcd_6 =1;
if(lcd_a3 & bit3) {lcd_7 =0;} else{lcd_7 =1;} //3d
//if(lcd_a) {lcd_8 =0;} else{lcd_8 =1;} //℃(显示)
lcd_8 =0;
if(lcd_a4 & bit3) {lcd_9 =0;} else{lcd_9 =1;} //4d
//if(lcd_a) {lcd_10 =0;} else{lcd_10 =1;} //点(显示)
lcd_10 =0;
if(lcd_a5 & bit3) {lcd_11 =0;} else{lcd_11 =1;} //5d
//if(lcd_a) {lcd_12 =0;} else{lcd_12 =1;} //停止
lcd_12 =1;
com1_ban;
com2_ban;
com3_ban;
com4_gao; //com4高
yanshi();
/**************************************************/ //lcd反控
com1_ban;
com2_ban;
com3_ban;
com4_ban;
if(lcd_a1 & bit5) {lcd_1 =1;} else{lcd_1 =0;}
if(lcd_a1 & bit0) {lcd_2 =1;} else{lcd_2 =0;}
if(lcd_a2 & bit5) {lcd_3 =1;} else{lcd_3 =0;}
if(lcd_a2 & bit0) {lcd_4 =1;} else{lcd_4 =0;}
//if(lcd_a2){lcd_5 =1;} else{lcd_5 =0;} //02竖(显示)
lcd_5 =1;
if(lcd_a3 & bit5) {lcd_6 =1;} else{lcd_6 =0;}
if(lcd_a3 & bit0) {lcd_7 =1;} else{lcd_7 =0;}
if(lcd_a4 & bit5) {lcd_8 =1;} else{lcd_8 =0;}
if(lcd_a4 & bit0) {lcd_9 =1;} else{lcd_9 =0;}
if(lcd_a5 & bit5) {lcd_10 =1;} else{lcd_10 =0;}
if(lcd_a5 & bit0) {lcd_11 =1;} else{lcd_11 =0;}
//if(lcd_a) {lcd_12 =1;} else{lcd_12 =0;} //01锁定
lcd_12 =0;
com1_di; //com1低
com2_ban;
com3_ban;
com4_ban;
yanshi();
com1_ban;
com2_ban;
com3_ban;
com4_ban;
if(lcd_a1 & bit6) {lcd_1 =1;} else{lcd_1 =0;}
if(lcd_a1 & bit1) {lcd_2 =1;} else{lcd_2 =0;}
if(lcd_a2 & bit6) {lcd_3 =1;} else{lcd_3 =0;}
if(lcd_a2 & bit1) {lcd_4 =1;} else{lcd_4 =0;} //防冻
//if(lcd_a) {lcd_5 =1;} else{lcd_5 =0;}
lcd_5 =0;
if(lcd_a3 & bit6) {lcd_6 =1;} else{lcd_6 =0;}
if(lcd_a3 & bit1) {lcd_7 =1;} else{lcd_7 =0;}
if(lcd_a4 & bit6) {lcd_8 =1;} else{lcd_8 =0;}
if(lcd_a4 & bit1) {lcd_9 =1;} else{lcd_9 =0;}
if(lcd_a5 & bit6) {lcd_10 =1;} else{lcd_10 =0;}
if(lcd_a5 & bit1) {lcd_11 =1;} else{lcd_11 =0;}
//if(lcd_a) {lcd_12 =1;} else{lcd_12 =0;} //中
lcd_12 =0;
com1_ban;
com2_di; //com2低
com3_ban;
com4_ban;
yanshi();
com1_ban;
com2_ban;
com3_ban;
com4_ban;
if(lcd_a1 & bit4) {lcd_1 =1;} else{lcd_1 =0;}
if(lcd_a1 & bit2) {lcd_2 =1;} else{lcd_2 =0;}
if(lcd_a2 & bit4) {lcd_3 =1;} else{lcd_3 =0;}
if(lcd_a2 & bit2) {lcd_4 =1;} else{lcd_4 =0;}
//if(lcd_a) {lcd_5 =1;} else{lcd_5 =0;} //保护
lcd_5 =0;
if(lcd_a3 & bit4) {lcd_6 =1;} else{lcd_6 =0;}
if(lcd_a3 & bit2) {lcd_7 =1;} else{lcd_7 =0;}
if(lcd_a4 & bit4) {lcd_8 =1;} else{lcd_8 =0;}
if(lcd_a4 & bit2) {lcd_9 =1;} else{lcd_9 =0;}
if(lcd_a5 & bit4) {lcd_10 =1;} else{lcd_10 =0;}
if(lcd_a5 & bit2) {lcd_11 =1;} else{lcd_11 =0;}
//if(lcd_a) {lcd_12 =1;} else{lcd_12 =0;} //加热
lcd_12 =0;
com1_ban;
com2_ban;
com3_di; //com3低
com4_ban;
yanshi();
com1_ban;
com2_ban;
com3_ban;
com4_ban;
//if(lcd_a) {lcd_1 =1;} else{lcd_1 =0;} //室温
lcd_1 =0;
if(lcd_a1 & bit3) {lcd_2 =1;} else{lcd_2 =0;}
//if(lcd_a) {lcd_3 =1;} else{lcd_3 =0;} //设定摄氏度(显示)
lcd_3 =1;
if(lcd_a2 & bit3) {lcd_4 =1;} else{lcd_4 =0;}
//if(lcd_a) {lcd_5 =1;} else{lcd_5 =0;} //无
lcd_5 =0;
//if(lcd_a) {lcd_6 =1;} else{lcd_6 =0;} //地温
lcd_6 =0;
if(lcd_a3 & bit3) {lcd_7 =1;} else{lcd_7 =0;}
//if(lcd_a) {lcd_8 =1;} else{lcd_8 =0;} //℃(显示)
lcd_8 =1;
if(lcd_a4 & bit3) {lcd_9 =1;} else{lcd_9 =0;}
//if(lcd_a) {lcd_10 =1;} else{lcd_10 =0;} //点(显示)
lcd_10 =1;
if(lcd_a5 & bit3) {lcd_11 =1;} else{lcd_11 =0;}
//if(lcd_a) {lcd_12 =1;} else{lcd_12 =0;} //停止
lcd_12 =0;
com1_ban;
com2_ban;
com3_ban;
com4_di; //com4低
yanshi();
}
/**************************************************/
void jisuan() //计算
{
lcd_a1 =biao[xs_a3/1000];
lcd_a2 =biao[(xs_a3%1000)/100];
lcd_a3 =biao[(xs_a3%100)/10];
lcd_a4 =biao[xs_a3%10];
lcd_a5 =biao[xs_a2%10];
}
/**************************************************/
void yanshi() //延时
{
unsigned char x,y;
for(x=50;x>0;x--)
for(y=100;y>0;y--);
}
/**************************************************/
/**************************************************/
/**************************************************/
/**************************************************/
/**************************************************/
|