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

📄 main.lst

📁 自己写的测试程序,调试已通过,可以直接使用, 而且有的还有详细的注释.红外测试软件
💻 LST
📖 第 1 页 / 共 5 页
字号:
 950   1      
 951   1       command=0x07;
 952   1       EX1=0;
 953   1       ch451_load=0;
 954   1       for(i=0;i<4;i++)
 955   1       {
 956   2        ch451_din=command&1;
 957   2        ch451_clk=0;
 958   2         command>>=1;
 959   2        ch451_clk=1;
 960   2       }
 961   1       ch451_load=1;
 962   1       keycode=0;
 963   1       for(i=0;i<7;i++)
 964   1        {
 965   2        keycode<<=1; 
 966   2        keycode|=ch451_dout;
 967   2        ch451_clk=0;
 968   2        ch451_clk=1;
 969   2        }
 970   1       
 971   1       EX1=1;            // open outinterrupt
 972   1       IE1=0;            // interrupt flag bit ;
 973   1      
C51 COMPILER V7.06   MAIN                                                                  03/26/2008 16:30:50 PAGE 17  

 974   1       
 975   1      return(keycode);
 976   1        }
 977          
 978           /*************** initialization all function ********************/
 979          void initialization()
 980          {
 981   1       
 982   1        TMOD=0x01;          /*工作模式,定时器0*/
 983   1        TH0=0x3c;
 984   1        TL0=0xb0;         
 985   1        EA=1; 
 986   1        ET0=1;
 987   1        TR0=1;              /*启动定时器器*/
 988   1      
 989   1           EX1=0;              // out interrupt 
 990   1      
 991   1      
 992   1               PX1=0;              // 优先级
 993   1               IT1=1;              // 边沿触发(下降沿有效)
 994   1      
 995   1      /************************/
 996   1              TMOD|= 0x20;
 997   1              SCON = 0x50;
 998   1              TH1 = 0xf4;
 999   1              TL1 = 0xf4;
1000   1              PCON = 0x00;                                            // SMOD=0
1001   1      
1002   1         TR1  = 1;       /* 定时器1启动计数*/
1003   1         ES   = 0;       /* 串口开中断     */
1004   1         PS   = 0;       /* 串口低优先级   */
1005   1         REN  = 1;       /* 串口接收允许   */
1006   1         EA   = 1;       /* 开CPU中断      */
1007   1         DE=0;
1008   1      /*************************/
1009   1      
1010   1        
1011   1        initialization_led_screen();
1012   1                                                                                             // There have lcd_s
             -crren error! 
1013   1       // ds18b20_start();
1014   1        
1015   1        key_flag=0; 
1016   1             delay_iic();
1017   1            read_iic_data(1,&iic_read,0,1);      
1018   1            if(iic_read[0]==-1|iic_read[0]>64|iic_read[0]<0){memery_error();}   //存储器故障!
1019   1        start();       
1020   1      
1021   1            if(iic_read[0]==0)                               // read two times
1022   1                       {    lcd_screen_blank();
1023   2                        found_new(); 
1024   2                        display_set();
1025   2                                        }
1026   1              display_set(); 
1027   1      
1028   1        ch451_init();  
1029   1        ch451_write(0x406);
1030   1         
1031   1      
1032   1       } 
1033           //******************    off    *********************************************//
1034           void off(void)
C51 COMPILER V7.06   MAIN                                                                  03/26/2008 16:30:50 PAGE 18  

1035           {
1036   1                    clear_lcd_screen();
1037   1        
1038   1             
1039   1                    write_word(0,3,16,&chinese[63]);  // 重新启动中……
1040   1                    write_word(0,3,32,&chinese[39]);
1041   1                    write_word(0,3,48,&chinese[64]);  
1042   1                    write_word(1,3,0,&chinese[65]); 
1043   1                                                                write_byte(1,3,30,&number[24]);
1044   1                    write_word(1,3,16,&chinese[36]);
1045   1      
1046   1                    
1047   1                    write_byte(1,3,34,&number[24]);
1048   1                    write_byte(1,3,38,&number[24]);
1049   1                    write_byte(1,3,42,&number[24]);
1050   1                    write_byte(1,3,46,&number[24]);
1051   1                   // write_byte(1,3,50,&number[24]);
1052   1      
1053   1      
1054   1               delay_1s(20000);
1055   1        EA=0;
1056   1        while(1);
1057   1        }
1058          /*******************  myselfe_number  ******************************/
1059          void myselfe_number(void)
1060          {
1061   1        unsigned char o1,o2;
1062   1        clear_lcd_screen();
1063   1        write_word(0,3,16,&chinese[18]);            //write input a word "本"
1064   1        write_word(0,3,32,&chinese[19]);           //write input a word "机"
1065   1        write_word(0,3,48,&chinese[20]);           //write input a word "编"
1066   1        write_word(1,3,0,&chinese[21]);           //write input a word "号"
1067   1        write_byte(1,3,16,&number[22]);             //write input a byte ":"
1068   1       
1069   1        read_iic_data(1,&iic_read,5,1);
1070   1        o1=iic_read[0]/100;
1071   1        write_byte(1,3,24,&number[o1]);
1072   1        o2=(iic_read[0]-o1*100)/10;
1073   1        write_byte(1,3,32,&number[o2]);
1074   1        o1=(iic_read[0]-o1*100-o2*10)%10;
1075   1        write_byte(1,3,40,&number[o1]);
1076   1       key_delay(60000);
1077   1       key_delay(60000);
1078   1       clear_lcd_screen();
1079   1      }
1080          /*******************  myselfe_number  ******************************/
1081          void myselfe_number_1(void)
1082          {
1083   1        unsigned char o1,o2;
1084   1      
1085   1        write_word(0,0,18,&chinese[18]);            //write input a word "本"
1086   1        write_word(0,0,34,&chinese[19]);           //write input a word "机"
1087   1        write_word(0,0,50,&chinese[20]);           //write input a word "编"
1088   1        write_word(1,0,1,&chinese[21]);           //write input a word "号"
1089   1        write_byte(1,0,16,&number[22]);             //write input a byte ":"
1090   1       
1091   1        read_iic_data(1,&iic_read,5,1);
1092   1        o1=iic_read[0]/100;
1093   1        write_byte(1,0,24,&number[o1]);
1094   1        o2=(iic_read[0]-o1*100)/10;
1095   1        write_byte(1,0,32,&number[o2]);
1096   1        o1=(iic_read[0]-o1*100-o2*10)%10;
C51 COMPILER V7.06   MAIN                                                                  03/26/2008 16:30:50 PAGE 19  

1097   1        write_byte(1,0,40,&number[o1]);
1098   1      }
1099          
1100          //**********  给写到LCD SCREEN 的数据求反  ***************/
1101          void changed(bit x,bit k,unsigned char  y[])  
1102           {
1103   1        unsigned char i;
1104   1        unsigned char *p;
1105   1        p=y;
1106   1      
1107   1        if(x==0)
1108   1           {
1109   2                for(i=0;i<16;i++)
1110   2                 {
1111   3                   if(k==1)
1112   3                         {change_byte[i]=~*p;
1113   4                     p++;}
1114   3                         else 
1115   3                           {
1116   4                                change_byte[i]=*p;
1117   4                                p++;
1118   4                                }
1119   3                   }}
1120   1         if(x==1)
1121   1         {
1122   2        for(i=0;i<32;i++)
1123   2        {   
1124   3           if(k==1)
1125   3            {
1126   4                change_word[i]=~*p;
1127   4               p++;
1128   4                }
1129   3                else 
1130   3                 {
1131   4                  change_word[i]=*p;
1132   4                      p++;
1133   4                      }
1134   3           }}
1135   1       }
1136          /**************     setup succeed  ************************************/
1137          void setup_succeed(void)
1138          {                                                                     
1139   1        clear_lcd_screen();
1140   1        write_word(0,3,32,&chinese[66]);
1141   1        write_word(0,3,48,&chinese[67]);  
1142   1        write_word(1,3,0,&chinese[55]);
1143   1        write_word(1,3,16,&chinese[56]);
1144   1        write_byte(1,3,32,&number[23]); 
1145   1        key_delay(60000);key_delay(60000);
1146   1        clear_lcd_screen();
1147   1        }
1148          /****************  setup unceed  **************************/
1149          void setup_unsucceed(void)
1150          {                                                                     
1151   1        clear_lcd_screen();
1152   1        write_word(0,3,24,&chinese[25]);
1153   1        write_word(0,3,40,&chinese[26]);  
1154   1        write_word(0,3,56,&chinese[17]);
1155   1        write_word(1,3,8,&chinese[114]);
1156   1        write_word(1,3,24,&chinese[115]);
1157   1      
1158   1        write_byte(1,3,40,&number[23]); 
C51 COMPILER V7.06   MAIN                                                                  03/26/2008 16:30:50 PAGE 20  

1159   1        key_delay(60000);key_delay(60000);
1160   1        clear_lcd_screen();
1161   1        }
1162          /*****************    key  *********************************************/
1163          
1164            
1165          void key(void)
1166          {
1167   1       unsigned char i,key_value,ff,bb,ss,display_mode;
1168   1       unsigned char change_value;
1169   1       unsigned char page;
1170   1       int temp;
1171   1       bit minus_flag;
1172   1       bit row1,row2,row3,row4;
1173   1       float temperature_value;                      // ES=0;
1174   1      
1175   1      
1176   1      
1177   1      //  unsigned long int n1;
1178   1      //  float g_value;
1179   1      //   short int voltage;   
1180   1       
1181   1           key_value=key_code();                                                      
1182   1               key_flag=0;
1183   1                                  //if(key_flag==1){while(1);}
1184   1                       if(key_value==0x58|key_value==0x18)
1185   1                              {  
1186   2                                                                clear_lcd_screen();
1187   2                                              write_word(0,3,40,&chinese[22]);
1188   2                                              write_word(0,3,56,&chinese[106]);
1189   2                                              write_word(1,3,8,&chinese[107]);
1

⌨️ 快捷键说明

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