/***************SC92F7323+LCD88888*****************/
/***************QQ:74145445************************/
/*************快手:共同学习STM8********************/
/*************keiluvision2*************************/
/*************20210808*****************************/
/**************************************************/
// lcd88888
//|1|2|3|4|5|6|7|8|9|10|11|12|com_4|com_3|com_2|com_1|
//SC92F7323 ________ ________
// 5V-|1 /VDD \_/ P0.0/28|-com_1
// 0V-|2 /VSS P0.1/27|-com_2
// -|3 /P5.1 P0.2/26|-com_3
// -|4 /P5.0 P0.3/25|-com_4
// -|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>
#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 com_1_gao P0VO &= ~bit0; P00=1
#define com_1_ban P0VO |=bit0
#define com_1_di P0VO &= ~bit0; P00=0
#define com_2_gao P0VO &= ~bit1; P01=1
#define com_2_ban P0VO |=bit1
#define com_2_di P0VO &= ~bit1; P01=0
#define com_3_gao P0VO &= ~bit2; P02=1
#define com_3_ban P0VO |=bit2
#define com_3_di P0VO &= ~bit2; P02=0
#define com_4_gao P0VO &= ~bit3; P03=1
#define com_4_ban P0VO |=bit3
#define com_4_di P0VO &= ~bit3; P03=0
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 temp_a1; //设定温度
unsigned char temp_a2; //室温
//unsigned char temp_a3; //地温
unsigned char temp_b1; //设定温度十位
unsigned char temp_b2; //设定温度个位
unsigned char temp_b3; //室温十位
unsigned char temp_b4; //室温个位
unsigned char temp_b5; //室温小数
unsigned char temp_c1; //设定温度十位字模
unsigned char temp_c2; //设定温度个位字模
unsigned char temp_c3; //室温十位字模
unsigned char temp_c4; //室温个位字模
unsigned char temp_c5; //室温小数字模
unsigned char code biao[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
/**************************************************/
void lcd_xianshi(); //lcd显示
void jisuan(); //计算
void yanshi(); //延时
/**************************************************/
void main()
{
/**************************************************/ //液晶初始化
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; //背光输出
temp_a1 =12;
temp_a2 =34;
temp_b5 =5;
/**************************************************/
P1CON |=bit4;
P1 |=bit4;
beiguang =1;
jisuan();
while (1)
{
lcd_xianshi();
}
}
/**************************************************/
void lcd_xianshi() //lcd显示
{
/**************************************************/ //lcd正控
com_1_ban;
com_2_ban;
com_3_ban;
com_4_ban;
if(temp_c1&bit5){lcd_1 =0;} else{lcd_1 =1;}
if(temp_c1&bit0){lcd_2 =0;} else{lcd_2 =1;}
if(temp_c2&bit5){lcd_3 =0;} else{lcd_3 =1;}
if(temp_c2&bit0){lcd_4 =0;} else{lcd_4 =1;}
//if(temp_){lcd_5 =0;} else{lcd_5 =1;} //02竖(显示)
lcd_5 =0;
if(temp_c3&bit5){lcd_6 =0;} else{lcd_6 =1;}
if(temp_c3&bit0){lcd_7 =0;} else{lcd_7 =1;}
if(temp_c4&bit5){lcd_8 =0;} else{lcd_8 =1;}
if(temp_c4&bit0){lcd_9 =0;} else{lcd_9 =1;}
if(temp_c5&bit5){lcd_10 =0;} else{lcd_10 =1;}
if(temp_c5&bit0){lcd_11 =0;} else{lcd_11 =1;}
//if(temp_){lcd_12 =0;} else{lcd_12 =1;} //01锁定
lcd_12 =1;
com_1_gao; //com1高
com_2_ban;
com_3_ban;
com_4_ban;
yanshi();
com_1_ban;
com_2_ban;
com_3_ban;
com_4_ban;
if(temp_c1&bit6){lcd_1 =0;} else{lcd_1 =1;}
if(temp_c1&bit1){lcd_2 =0;} else{lcd_2 =1;}
if(temp_c2&bit6){lcd_3 =0;} else{lcd_3 =1;}
if(temp_c2&bit1){lcd_4 =0;} else{lcd_4 =1;}
//if(temp_){lcd_5 =0;} else{lcd_5 =1;} //防冻
lcd_5 =1;
if(temp_c3&bit6){lcd_6 =0;} else{lcd_6 =1;}
if(temp_c3&bit1){lcd_7 =0;} else{lcd_7 =1;}
if(temp_c4&bit6){lcd_8 =0;} else{lcd_8 =1;}
if(temp_c4&bit1){lcd_9 =0;} else{lcd_9 =1;}
if(temp_c5&bit6){lcd_10 =0;} else{lcd_10 =1;}
if(temp_c5&bit1){lcd_11 =0;} else{lcd_11 =1;}
//if(temp_){lcd_12 =0;} else{lcd_12 =1;} //中
lcd_12 =1;
com_1_ban;
com_2_gao; //com2高
com_3_ban;
com_4_ban;
yanshi();
com_1_ban;
com_2_ban;
com_3_ban;
com_4_ban;
if(temp_c1&bit4){lcd_1 =0;} else{lcd_1 =1;}
if(temp_c1&bit2){lcd_2 =0;} else{lcd_2 =1;}
if(temp_c2&bit4){lcd_3 =0;} else{lcd_3 =1;}
if(temp_c2&bit4){lcd_4 =0;} else{lcd_4 =1;}
//if(temp_){lcd_5 =0;} else{lcd_5 =1;} //保护
lcd_5 =1;
if(temp_c3&bit4){lcd_6 =0;} else{lcd_6 =1;}
if(temp_c3&bit2){lcd_7 =0;} else{lcd_7 =1;}
if(temp_c4&bit4){lcd_8 =0;} else{lcd_8 =1;}
if(temp_c4&bit2){lcd_9 =0;} else{lcd_9 =1;}
if(temp_c5&bit4){lcd_10 =0;} else{lcd_10 =1;}
if(temp_c5&bit2){lcd_11 =0;} else{lcd_11 =1;}
//if(temp_){lcd_12 =0;} else{lcd_12 =1;} //加热
lcd_12 =1;
com_1_ban;
com_2_ban;
com_3_gao; //com3高
com_4_ban;
yanshi();
com_1_ban;
com_2_ban;
com_3_ban;
com_4_ban;
//if(temp_){lcd_1 =0;} else{lcd_1 =1;} //室温
lcd_1 =1;
if(temp_c1&bit3){lcd_2 =0;} else{lcd_2 =1;}
//if(temp_){lcd_3 =0;} else{lcd_3 =1;} //设定摄氏度(显示)
lcd_3 =0;
if(temp_c2&bit3){lcd_4 =0;} else{lcd_4 =1;} //无
//if(temp_){lcd_5 =0;} else{lcd_5 =1;}
lcd_5 =1;
//if(temp_){lcd_6 =0;} else{lcd_6 =1;} //地温
lcd_6 =1;
if(temp_c3&bit3){lcd_7 =0;} else{lcd_7 =1;}
//if(temp_){lcd_8 =0;} else{lcd_8 =1;} //℃(显示)
lcd_8 =0;
if(temp_c4&bit3){lcd_9 =0;} else{lcd_9 =1;}
//if(temp_){lcd_10 =0;} else{lcd_10 =1;} //点(显示)
lcd_10 =0;
if(temp_c5&bit3){lcd_11 =0;} else{lcd_11 =1;}
//if(temp_){lcd_12 =0;} else{lcd_12 =1;} //停止
lcd_12 =1;
com_1_ban;
com_2_ban;
com_3_ban;
com_4_gao; //com4高
yanshi();
/**************************************************/ //lcd反控
com_1_ban;
com_2_ban;
com_3_ban;
com_4_ban;
if(temp_c1&bit5){lcd_1 =1;} else{lcd_1 =0;}
if(temp_c1&bit0){lcd_2 =1;} else{lcd_2 =0;}
if(temp_c2&bit5){lcd_3 =1;} else{lcd_3 =0;}
if(temp_c2&bit0){lcd_4 =1;} else{lcd_4 =0;}
//if(temp_){lcd_5 =1;} else{lcd_5 =0;} //02竖(显示)
lcd_5 =1;
if(temp_c3&bit5){lcd_6 =1;} else{lcd_6 =0;}
if(temp_c3&bit0){lcd_7 =1;} else{lcd_7 =0;}
if(temp_c4&bit5){lcd_8 =1;} else{lcd_8 =0;}
if(temp_c4&bit0){lcd_9 =1;} else{lcd_9 =0;}
if(temp_c5&bit5){lcd_10 =1;} else{lcd_10 =0;}
if(temp_c5&bit0){lcd_11 =1;} else{lcd_11 =0;}
//if(temp_){lcd_12 =1;} else{lcd_12 =0;} //01锁定
lcd_12 =0;
com_1_di; //com1低
com_2_ban;
com_3_ban;
com_4_ban;
yanshi();
com_1_ban;
com_2_ban;
com_3_ban;
com_4_ban;
if(temp_c1&bit6){lcd_1 =1;} else{lcd_1 =0;}
if(temp_c1&bit1){lcd_2 =1;} else{lcd_2 =0;}
if(temp_c2&bit6){lcd_3 =1;} else{lcd_3 =0;}
if(temp_c2&bit1){lcd_4 =1;} else{lcd_4 =0;} //防冻
//if(temp_){lcd_5 =1;} else{lcd_5 =0;}
lcd_5 =0;
if(temp_c3&bit6){lcd_6 =1;} else{lcd_6 =0;}
if(temp_c3&bit1){lcd_7 =1;} else{lcd_7 =0;}
if(temp_c4&bit6){lcd_8 =1;} else{lcd_8 =0;}
if(temp_c4&bit1){lcd_9 =1;} else{lcd_9 =0;}
if(temp_c5&bit6){lcd_10 =1;} else{lcd_10 =0;}
if(temp_c5&bit1){lcd_11 =1;} else{lcd_11 =0;}
//if(temp_){lcd_12 =1;} else{lcd_12 =0;} //中
lcd_12 =0;
com_1_ban;
com_2_di; //com2低
com_3_ban;
com_4_ban;
yanshi();
com_1_ban;
com_2_ban;
com_3_ban;
com_4_ban;
if(temp_c1&bit4){lcd_1 =1;} else{lcd_1 =0;}
if(temp_c1&bit2){lcd_2 =1;} else{lcd_2 =0;}
if(temp_c2&bit4){lcd_3 =1;} else{lcd_3 =0;}
if(temp_c2&bit2){lcd_4 =1;} else{lcd_4 =0;}
//if(temp_){lcd_5 =1;} else{lcd_5 =0;} //保护
lcd_5 =0;
if(temp_c3&bit4){lcd_6 =1;} else{lcd_6 =0;}
if(temp_c3&bit2){lcd_7 =1;} else{lcd_7 =0;}
if(temp_c4&bit4){lcd_8 =1;} else{lcd_8 =0;}
if(temp_c4&bit2){lcd_9 =1;} else{lcd_9 =0;}
if(temp_c5&bit4){lcd_10 =1;} else{lcd_10 =0;}
if(temp_c5&bit2){lcd_11 =1;} else{lcd_11 =0;}
//if(temp_){lcd_12 =1;} else{lcd_12 =0;} //加热
lcd_12 =0;
com_1_ban;
com_2_ban;
com_3_di; //com3低
com_4_ban;
yanshi();
com_1_ban;
com_2_ban;
com_3_ban;
com_4_ban;
//if(temp_){lcd_1 =1;} else{lcd_1 =0;} //室温
lcd_1 =0;
if(temp_c1&bit3){lcd_2 =1;} else{lcd_2 =0;}
//if(temp_){lcd_3 =1;} else{lcd_3 =0;} //设定摄氏度(显示)
lcd_3 =1;
if(temp_c2&bit3){lcd_4 =1;} else{lcd_4 =0;}
//if(temp_){lcd_5 =1;} else{lcd_5 =0;} //无
lcd_5 =0;
//if(temp_){lcd_6 =1;} else{lcd_6 =0;} //地温
lcd_6 =0;
if(temp_c3&bit3){lcd_7 =1;} else{lcd_7 =0;}
//if(temp_){lcd_8 =1;} else{lcd_8 =0;} //℃(显示
lcd_8 =1;
if(temp_c4&bit3){lcd_9 =1;} else{lcd_9 =0;}
//if(temp_){lcd_10 =1;} else{lcd_10 =0;} //点(显示)
lcd_10 =1;
if(temp_c5&bit3){lcd_11 =1;} else{lcd_11 =0;}
//if(temp_){lcd_12 =1;} else{lcd_12 =0;} //停止
lcd_12 =0;
com_1_ban;
com_2_ban;
com_3_ban;
com_4_di; //com4低
yanshi();
}
/**************************************************/
void jisuan() //计算
{
temp_b1 =temp_a1/10;
temp_b2 =temp_a1%10;
temp_c1 =biao[temp_b1];
//temp_c1 =biao[temp_a1/10];
temp_c2 =biao[temp_b2];
temp_b3 =temp_a2/10;
temp_b4 =temp_a2%10;
temp_c3 =biao[temp_b3];
temp_c4 =biao[temp_b4];
temp_c5 =biao[temp_b5];
}
/**************************************************/
/**************************************************/
void yanshi() //延时
{
unsigned char x,y;
for(x=50;x>0;x--)
for(y=100;y>0;y--);
}
/**************************************************/
|