切换到宽版
  • 2075阅读
  • 52回复

[另类]脚位搞反不要紧,曲线(飞线)救国(板),脚位倒转成功 [复制链接]

上一主题 下一主题
离线zhkrid

发帖
15845
M币
56485
专家
195
粉丝
197
只看该作者 50楼 发表于: 10-13
Re:回 zhkrid 的帖子
2545889167:
应该是没问题。你把改完飞线线序后的引脚和你现在的1602写数据的程序部分贴出来,我试试给你改改看。。主要说说12脚打算飞到哪儿 Re:回 zhkrid 的帖子


12脚飞到P3.3(封装9脚)
显示相关程序如下,麻烦你帮忙看下
  1. #include<stc12c5a60s2.h>
  2. #include"stdio.h"
  3. #include"intrins.h"
  4. #define uint unsigned int
  5. #define uchar unsigned char
  6. sbit v_cd=P3^5;
  7. sbit v_fd=P3^4;
  8. sbit key=P2^0;
  9. sbit lcdrs=P2^3;
  10. sbit lcden=P2^4;
  11. 中间省略
  12. /**********************************************************/
  13. void write_com(uchar com)            //1602 lcd
  14. {
  15.     lcdrs=0;
  16.     lcden=1;
  17.     P0=com;
  18.     delayms(5);
  19.     lcden=0;
  20. }
  21. /**********************************************************/
  22. void write_data(uchar date)        //1602 lcd
  23. {
  24.     lcdrs=1;
  25.     lcden=1;
  26.     P0=date;
  27.     delayms(5);
  28.     lcden=0;
  29. }
  30. /**********************************************************/
  31. void lcd_init()    //lcd3õê¼»ˉ
  32. {
  33.      write_com(0x38);
  34.      delayms(20);
  35.      write_com(0x38);
  36.      delayms(20);
  37.             write_com(0x0c);
  38.      delayms(20);
  39.             write_com(0x06);
  40.      delayms(20);
  41.             write_com(0x01);
  42.      delayms(20);
  43. }
  44. void AD_init()
  45. 以下省略

本文内容包含图片或附件,获取更多资讯,请 登录 后查看;或者 注册 成为会员获得更多权限
本帖最近打赏记录:共1条打赏M币+1
2545889167 M币 +1 楼下 10-13
离线2545889167

发帖
11370
M币
35944
专家
177
粉丝
4424
只看该作者 51楼 发表于: 10-13
回 zhkrid 的帖子
zhkrid:
12脚飞到P3.3(封装9脚)
显示相关程序如下,麻烦你帮忙看下
....... 回 zhkrid 的帖子



我试着写了下。能不能用我没实物试验过。
你看看如果不能用我再改改看看
  1. sbit v_cd=P3^5;
  2. sbit v_fd=P3^4;
  3. sbit key=P2^0;
  4. sbit lcdrs=P0^6;
  5. sbit lcden=P0^4;
  6. sbit lcdrw=P0^5;
  7. sbit lcdd0=P0^3;
  8. sbit lcdd1=P0^2;
  9. sbit lcdd2=P0^1;
  10. sbit lcdd3=P0^0;
  11. sbit lcdd4=P2^4;
  12. sbit lcdd5=P3^3;
  13. sbit lcdd6=P2^3;
  14. sbit lcdd7=P0^7;
  15. void lcd_write_dat(uchar dat)
  16. {
  17. #pragma asm
  18.     MOV A,R7
  19.     RRL A
  20.     MOV lcdd0,C
  21.     RRL A
  22.     MOV lcdd1,C
  23.     RRL A
  24.     MOV lcdd2,C
  25.     RRL A
  26.     MOV lcdd3,C
  27.     RRL A
  28.     MOV lcdd4,C
  29.     RRL A
  30.     MOV lcdd5,C
  31.     RRL A
  32.     MOV lcdd6,C
  33.     RRL A
  34.     MOV lcdd7,C
  35. #pragma endasm    
  36. }
  37. /**********************************************************/
  38. void write_com(uchar com)            //1602 lcd
  39. {
  40.     lcdrs=0;
  41.     lcden=1;
  42.         lcd_write_dat(com);
  43.     delayms(5);
  44.     lcden=0;
  45. }
  46. /**********************************************************/
  47. void write_data(uchar date)        //1602 lcd
  48. {
  49.     lcdrs=1;
  50.     lcden=1;
  51.     lcd_write_dat(date);
  52.     delayms(5);
  53.     lcden=0;
  54. }
  55. void lcd_init()  
  56. {
  57.     lcdrw=0;
  58.     write_com(0x38);
  59.     delayms(20);
  60.     write_com(0x38);
  61.     delayms(20);
  62.     write_com(0x0c);
  63.     delayms(20);
  64.     write_com(0x06);
  65.     delayms(20);
  66.     write_com(0x01);
  67.     delayms(20);
  68. }
图方便嵌入了点汇编,要做一下几个设置
1、右键工程组,点第一个配置

2、红框里面两个勾起来

3、工程文件添加这个
这个文件在keil安装目录下\c51\lib里面,找到后复制到你的工程下面再添加到工程里面来


如果编译还不对可以参考;http://blog.csdn.net/toraloo/article/details/7795705
或者搜索keil c51嵌入汇编

还有就是有个警告,忽略 不影响程序工作



本文内容包含图片或附件,获取更多资讯,请 登录 后查看;或者 注册 成为会员获得更多权限
离线zhkrid

发帖
15845
M币
56485
专家
195
粉丝
197
只看该作者 52楼 发表于: 10-13
Re:回 zhkrid 的帖子
2545889167:
我试着写了下。能不能用我没实物试验过。
你看看如果不能用我再改改看看
....... Re:回 zhkrid 的帖子


编译出错,代码A9 语法错误
  1. Rebuild target 'Target 1'
  2. compiling 1602.c...
  3. 1602.c(96): warning C280: 'dat': unreferenced local variable
  4. assembling 1602.src...
  5. 1602.src(583): error A9: SYNTAX ERROR
  6. 1602.src(587): error A9: SYNTAX ERROR
  7. 1602.src(591): error A9: SYNTAX ERROR
  8. 1602.src(595): error A9: SYNTAX ERROR
  9. 1602.src(599): error A9: SYNTAX ERROR
  10. 1602.src(603): error A9: SYNTAX ERROR
  11. 1602.src(607): error A9: SYNTAX ERROR
  12. 1602.src(611): error A9: SYNTAX ERROR
  13. Target not created
报错主要在这



改后的C文件
  1. #include<stc12c5a60s2.h>
  2. #include"stdio.h"
  3. #include"intrins.h"
  4. #define uint unsigned int
  5. #define uchar unsigned char
  6. sbit v_cd=P3^5;
  7. sbit v_fd=P3^4;
  8. sbit key=P2^0;
  9. sbit lcdrs=P0^6;
  10. sbit lcden=P0^4;
  11. sbit lcdrw=P0^5;
  12. sbit lcdd0=P0^3;
  13. sbit lcdd1=P0^2;
  14. sbit lcdd2=P0^1;
  15. sbit lcdd3=P0^0;
  16. sbit lcdd4=P2^4;
  17. sbit lcdd5=P3^3;
  18. sbit lcdd6=P2^3;
  19. sbit lcdd7=P0^7;
  20. int volt,aolt,aolt_z,curr,mah;
  21. uchar key_flag=1;
  22. uchar num;
  23. uchar v_shi,v_ge,v_xiao1,v_xiao2;
  24. uchar a_shi,a_ge,a_xiao1,a_xiao2;
  25. uchar h_shi,h_ge,h_xiao1,h_xiao2;
  26. uchar t_shi,t_ge,t_xiao1,t_xiao2;
  27. uchar s,g,x1,x2;
  28. uchar data table[12]; //暂存数组,可以将10改为你需要的数值
  29. uint i=0;
  30. uchar code table1[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,};
  31. bit com_flag;
  32. uint time;
  33. uint num1,num2;
  34. bit time_flag;
  35. bit shan_flag;
  36. bit lcd_flag;
  37. void AD_init();
  38. unsigned int AD_get(unsigned char channel);
  39. void delayms(uint z);
  40. void delay(unsigned int a); //延时约1ms
  41. void UART_init(void);               //初始化函数
  42. void senddata(uchar dat);
  43. void write_com(uchar com);
  44. void write_data(uchar date);
  45. void lcd_init();
  46. void time_init();
  47. void lcd_write_dat(uchar dat);
  48. void delayms(uint z)
  49. {
  50.         uint x,y;
  51.         for(x=z;x>0;x--)
  52.             for(y=110;y>0;y--);
  53. }      
  54. /**********************************************************/
  55. void UART_init(void)               //初始化函 11.0592M
  56. {
  57.     SCON = 0x50;
  58.     TMOD = 0x21;
  59.     TH1  = 0xFD;                  //9600
  60.     TL1  = 0xFD;
  61.     TR1  = 1;
  62.     ES   = 1;
  63.     EA   = 1;
  64. }
  65. /**********************************************************/
  66. void senddata(uchar dat)
  67. {              
  68.     ES = 0;                       //关串口中断
  69.     TI = 0;                       //将串口发送完成中断请求标志清零
  70.     SBUF = dat;                //写数据到发送缓冲区
  71.     while(!TI);                   //等待发送完成
  72.     TI = 0;                       //将串口发送完成中断请求标志清零
  73.     ES = 1;                   //将串口发送完成中断请求标志清零
  74. }
  75. /* ***************************************************** */
  76. void delay(unsigned int a) //延时约1ms
  77. {
  78.         unsigned int i;
  79.         while (--a!=0)
  80.         for(i=600;i>0;i--);   //1T单片机i=600,若是12T单片机i=125
  81. }
  82. /*************************************************************/
  83. void lcd_write_dat(uchar dat)
  84. {
  85. #pragma asm
  86.     MOV A,R7
  87.     RRL A
  88.     MOV lcdd0,C
  89.     RRL A
  90.     MOV lcdd1,C
  91.     RRL A
  92.     MOV lcdd2,C
  93.     RRL A
  94.     MOV lcdd3,C
  95.     RRL A
  96.     MOV lcdd4,C
  97.     RRL A
  98.     MOV lcdd5,C
  99.     RRL A
  100.     MOV lcdd6,C
  101.     RRL A
  102.     MOV lcdd7,C
  103. #pragma endasm    
  104. }
  105. void write_com(uchar com)            //1602 lcd
  106. {
  107.     lcdrs=0;
  108.     lcden=1;
  109.         lcd_write_dat(com);
  110.     delayms(5);
  111.     lcden=0;
  112. }
  113. /**********************************************************/
  114. void write_data(uchar date)        //1602 lcd
  115. {
  116.     lcdrs=1;
  117.     lcden=1;
  118.     lcd_write_dat(date);
  119.     delayms(5);
  120.     lcden=0;
  121. }
  122. /**********************************************************/
  123. void lcd_init()    //lcd初始化
  124. {
  125.        lcdrw=0;
  126.      write_com(0x38);
  127.      delayms(20);
  128.      write_com(0x38);
  129.      delayms(20);
  130.             write_com(0x0c);
  131.      delayms(20);
  132.             write_com(0x06);
  133.      delayms(20);
  134.             write_com(0x01);
  135.      delayms(20);
  136. }

自动生成的SRC文件
  1. ; .\1602.SRC generated from: 1602.c
  2. ; COMPILER INVOKED BY:
  3. ;        D:\Program Files\keil\C51\BIN\C51.EXE 1602.c BROWSE DEBUG OBJECTEXTEND TABS(2) SRC(.\1602.SRC)
  4. $NOMOD51
  5. NAME    _1602
  6. P1M0    DATA    092H
  7. P0M1    DATA    093H
  8. P2M0    DATA    096H
  9. P1M1    DATA    091H
  10. P0    DATA    080H
  11. P3M0    DATA    0B2H
  12. P2M1    DATA    095H
  13. P1    DATA    090H
  14. P4M0    DATA    0B4H
  15. P3M1    DATA    0B1H
  16. P2    DATA    0A0H
  17. P5M0    DATA    0CAH
  18. P4M1    DATA    0B3H
  19. P3    DATA    0B0H
  20. P5M1    DATA    0C9H
  21. P4    DATA    0C0H
  22. AC    BIT    0D0H.6
  23. P5    DATA    0C8H
  24. EA    BIT    0A8H.7
  25. SPCTL    DATA    0CEH
  26. lcden    BIT    080H.4
  27. CF    BIT    0D8H.7
  28. CH    DATA    0F9H
  29. EADC    BIT    0A8H.5
  30. IE    DATA    0A8H
  31. CL    DATA    0E9H
  32. IAP_CMD    DATA    0C5H
  33. CCAP0H    DATA    0FAH
  34. CCAP1H    DATA    0FBH
  35. ADC_RES    DATA    0BDH
  36. IPH2    DATA    0B6H
  37. CCAP0L    DATA    0EAH
  38. CR    BIT    0D8H.6
  39. CCAP1L    DATA    0EBH
  40. CCAPM0    DATA    0DAH
  41. CCAPM1    DATA    0DBH
  42. ES    BIT    0A8H.4
  43. PADC    BIT    0B8H.5
  44. IP    DATA    0B8H
  45. lcdrs    BIT    080H.6
  46. RI    BIT    098H.0
  47. CY    BIT    0D0H.7
  48. TI    BIT    098H.1
  49. v_cd    BIT    0B0H.5
  50. lcdrw    BIT    080H.5
  51. CLK_DIV    DATA    097H
  52. IAP_ADDRH    DATA    0C3H
  53. v_fd    BIT    0B0H.4
  54. PS    BIT    0B8H.4
  55. SP    DATA    081H
  56. IAP_ADDRL    DATA    0C4H
  57. CMOD    DATA    0D9H
  58. CCON    DATA    0D8H
  59. PPCA    BIT    0B8H.7
  60. OV    BIT    0D0H.2
  61. ELVD    BIT    0A8H.6
  62. P4SW    DATA    0BBH
  63. P00    BIT    080H.0
  64. ADC_CONTR    DATA    0BCH
  65. SBUF    DATA    099H
  66. P10    BIT    090H.0
  67. P01    BIT    080H.1
  68. PCON    DATA    087H
  69. P20    BIT    0A0H.0
  70. P11    BIT    090H.1
  71. P02    BIT    080H.2
  72. P30    BIT    0B0H.0
  73. P21    BIT    0A0H.1
  74. P12    BIT    090H.2
  75. P03    BIT    080H.3
  76. SCON    DATA    098H
  77. P40    BIT    0C0H.0
  78. P31    BIT    0B0H.1
  79. P22    BIT    0A0H.2
  80. P13    BIT    090H.3
  81. P04    BIT    080H.4
  82. WAKE_CLKO    DATA    08FH
  83. TMOD    DATA    089H
  84. TCON    DATA    088H
  85. P50    BIT    0C8H.0
  86. P41    BIT    0C0H.1
  87. P32    BIT    0B0H.2
  88. P23    BIT    0A0H.3
  89. P14    BIT    090H.4
  90. P05    BIT    080H.5
  91. P51    BIT    0C8H.1
  92. P42    BIT    0C0H.2
  93. P33    BIT    0B0H.3
  94. P24    BIT    0A0H.4
  95. P15    BIT    090H.5
  96. P06    BIT    080H.6
  97. P52    BIT    0C8H.2
  98. P43    BIT    0C0H.3
  99. P34    BIT    0B0H.4
  100. P25    BIT    0A0H.5
  101. P16    BIT    090H.6
  102. P07    BIT    080H.7
  103. PLVD    BIT    0B8H.6
  104. P53    BIT    0C8H.3
  105. P44    BIT    0C0H.4
  106. P35    BIT    0B0H.5
  107. P26    BIT    0A0H.6
  108. P17    BIT    090H.7
  109. P45    BIT    0C0H.5
  110. P36    BIT    0B0H.6
  111. P27    BIT    0A0H.7
  112. P46    BIT    0C0H.6
  113. P37    BIT    0B0H.7
  114. P47    BIT    0C0H.7
  115. IE0    BIT    088H.1
  116. BUS_SPEED    DATA    0A1H
  117. IE1    BIT    088H.3
  118. IE2    DATA    0AFH
  119. AUXR    DATA    08EH
  120. B    DATA    0F0H
  121. IAP_CONTR    DATA    0C7H
  122. ACC    DATA    0E0H
  123. lcdd0    BIT    080H.3
  124. ET0    BIT    0A8H.1
  125. lcdd1    BIT    080H.2
  126. key    BIT    0A0H.0
  127. TF0    BIT    088H.5
  128. ET1    BIT    0A8H.3
  129. lcdd2    BIT    080H.1
  130. TF1    BIT    088H.7
  131. IP2    DATA    0B5H
  132. lcdd3    BIT    080H.0
  133. RB8    BIT    098H.2
  134. TH0    DATA    08CH
  135. lcdd4    BIT    0A0H.4
  136. TH1    DATA    08DH
  137. IT0    BIT    088H.0
  138. EX0    BIT    0A8H.0
  139. lcdd5    BIT    0B0H.3
  140. TB8    BIT    098H.3
  141. IT1    BIT    088H.2
  142. EX1    BIT    0A8H.2
  143. lcdd6    BIT    0A0H.3
  144. P    BIT    0D0H.0
  145. lcdd7    BIT    080H.7
  146. SM0    BIT    098H.7
  147. TL0    DATA    08AH
  148. SM1    BIT    098H.6
  149. TL1    DATA    08BH
  150. SM2    BIT    098H.5
  151. PT0    BIT    0B8H.1
  152. PT1    BIT    0B8H.3
  153. RS0    BIT    0D0H.3
  154. IAP_DATA    DATA    0C2H
  155. TR0    BIT    088H.4
  156. RS1    BIT    0D0H.4
  157. TR1    BIT    088H.6
  158. WDT_CONTR    DATA    0C1H
  159. PX0    BIT    0B8H.0
  160. PX1    BIT    0B8H.2
  161. PCA_PWM0    DATA    0F2H
  162. PCA_PWM1    DATA    0F3H
  163. P1ASF    DATA    09DH
  164. DPH    DATA    083H
  165. ADC_RESL    DATA    0BEH
  166. DPL    DATA    082H
  167. SPSTAT    DATA    0CDH
  168. IPH    DATA    0B7H
  169. S2BUF    DATA    09BH
  170. REN    BIT    098H.4
  171. S2CON    DATA    09AH
  172. BRT    DATA    09CH
  173. SADEN    DATA    0B9H
  174. SADDR    DATA    0A9H
  175. IAP_TRIG    DATA    0C6H
  176. AUXR1    DATA    0A2H
  177. F0    BIT    0D0H.5
  178. PSW    DATA    0D0H
  179. CCF0    BIT    0D8H.0
  180. SPDAT    DATA    0CFH
  181. CCF1    BIT    0D8H.1
  182. P0M0    DATA    094H
  183. ?PR?_delayms?1602    SEGMENT CODE
  184. ?PR?UART_init?1602   SEGMENT CODE
  185. ?PR?_senddata?1602   SEGMENT CODE
  186. ?PR?_delay?1602      SEGMENT CODE
  187. ?PR?_lcd_write_dat?1602                  SEGMENT CODE
  188. ?DT?_lcd_write_dat?1602                  SEGMENT DATA OVERLAYABLE
  189. ?PR?_write_com?1602  SEGMENT CODE
  190. ?PR?_write_data?1602 SEGMENT CODE
  191. ?PR?lcd_init?1602    SEGMENT CODE
  192. ?PR?AD_init?1602     SEGMENT CODE
  193. ?PR?time_init?1602   SEGMENT CODE
  194. ?PR?lcd_display?1602 SEGMENT CODE
  195. ?PR?keysean?1602     SEGMENT CODE
  196. ?PR?_AD_get?1602     SEGMENT CODE
  197. ?PR?main?1602        SEGMENT CODE
  198. ?PR?interrupt_uart?1602                  SEGMENT CODE
  199. ?PR?T0_time?1602     SEGMENT CODE
  200. ?C_INITSEG           SEGMENT CODE
  201. ?CO?1602             SEGMENT CODE
  202. ?DT?1602             SEGMENT DATA
  203. ?BI?1602             SEGMENT BIT
  204.     EXTRN    CODE (?C?FCASTI)
  205.     EXTRN    CODE (?C?FPMUL)
  206.     EXTRN    CODE (?C?FPDIV)
  207.     EXTRN    CODE (?C?FPSUB)
  208.     EXTRN    CODE (?C?CASTF)
  209.     EXTRN    CODE (?C?SIDIV)
  210.     EXTRN    CODE (?C?FPADD)
  211.     EXTRN    CODE (?C?IMUL)
  212.     EXTRN    CODE (?C?UIDIV)
  213.     EXTRN    CODE (?C_STARTUP)
  214.     PUBLIC    s
  215.     PUBLIC    i
  216.     PUBLIC    g
  217.     PUBLIC    num
  218.     PUBLIC    volt
  219.     PUBLIC    key_flag
  220.     PUBLIC    curr
  221.     PUBLIC    com_flag
  222.     PUBLIC    v_xiao2
  223.     PUBLIC    v_xiao1
  224.     PUBLIC    t_xiao2
  225.     PUBLIC    t_xiao1
  226.     PUBLIC    mah
  227.     PUBLIC    aolt
  228.     PUBLIC    time
  229.     PUBLIC    lcd_flag
  230.     PUBLIC    h_xiao2
  231.     PUBLIC    time_flag
  232.     PUBLIC    h_xiao1
  233.     PUBLIC    x2
  234.     PUBLIC    x1
  235.     PUBLIC    shan_flag
  236.     PUBLIC    a_xiao2
  237.     PUBLIC    a_xiao1
  238.     PUBLIC    v_ge
  239.     PUBLIC    t_ge
  240.     PUBLIC    v_shi
  241.     PUBLIC    t_shi
  242.     PUBLIC    h_ge
  243.     PUBLIC    a_ge
  244.     PUBLIC    h_shi
  245.     PUBLIC    aolt_z
  246.     PUBLIC    table
  247.     PUBLIC    a_shi
  248.     PUBLIC    num2
  249.     PUBLIC    num1
  250.     PUBLIC    table1
  251.     PUBLIC    T0_time
  252.     PUBLIC    interrupt_uart
  253.     PUBLIC    main
  254.     PUBLIC    _AD_get
  255.     PUBLIC    keysean
  256.     PUBLIC    lcd_display
  257.     PUBLIC    time_init
  258.     PUBLIC    AD_init
  259.     PUBLIC    lcd_init
  260.     PUBLIC    _write_data
  261.     PUBLIC    _write_com
  262.     PUBLIC    _lcd_write_dat
  263.     PUBLIC    _delay
  264.     PUBLIC    _senddata
  265.     PUBLIC    UART_init
  266.     PUBLIC    _delayms
  267.     RSEG  ?DT?_lcd_write_dat?1602
  268. ?_lcd_write_dat?BYTE:
  269.         dat?446:   DS   1
  270.     RSEG  ?DT?1602
  271.            num1:   DS   2
  272.            num2:   DS   2
  273.           a_shi:   DS   1
  274.           table:   DS   12
  275.          aolt_z:   DS   2
  276.           h_shi:   DS   1
  277.            a_ge:   DS   1
  278.            h_ge:   DS   1
  279.           t_shi:   DS   1
  280.           v_shi:   DS   1
  281.            t_ge:   DS   1
  282.            v_ge:   DS   1
  283.         a_xiao1:   DS   1
  284.         a_xiao2:   DS   1
  285.              x1:   DS   1
  286.              x2:   DS   1
  287.         h_xiao1:   DS   1
  288.         h_xiao2:   DS   1
  289.            time:   DS   2
  290.            aolt:   DS   2
  291.             mah:   DS   2
  292.         t_xiao1:   DS   1
  293.         t_xiao2:   DS   1
  294.         v_xiao1:   DS   1
  295.         v_xiao2:   DS   1
  296.            curr:   DS   2
  297.        key_flag:   DS   1
  298.            volt:   DS   2
  299.             num:   DS   1
  300.               g:   DS   1
  301.               i:   DS   2
  302.               s:   DS   1
  303.     RSEG  ?BI?1602
  304.       shan_flag:   DBIT   1
  305.       time_flag:   DBIT   1
  306.        lcd_flag:   DBIT   1
  307.        com_flag:   DBIT   1
  308.     RSEG  ?CO?1602
  309. table1:
  310.     DB    030H
  311.     DB    031H
  312.     DB    032H
  313.     DB    033H
  314.     DB    034H
  315.     DB    035H
  316.     DB    036H
  317.     DB    037H
  318.     DB    038H
  319.     DB    039H
  320.     RSEG  ?C_INITSEG
  321.     DB    001H
  322.     DB    key_flag
  323.     DB    001H
  324.     DB    002H
  325.     DB    i
  326.     DW    00000H
  327. ; #include<stc12c5a60s2.h>
  328. ; #include"stdio.h"
  329. ; #include"intrins.h"
  330. ;
  331. ; #define uint unsigned int
  332. ; #define uchar unsigned char
  333. ;
  334. ; sbit v_cd=P3^5;
  335. ; sbit v_fd=P3^4;
  336. ; sbit key=P2^0;
  337. ; sbit lcdrs=P0^6;
  338. ; sbit lcden=P0^4;
  339. ; sbit lcdrw=P0^5;
  340. ;
  341. ; sbit lcdd0=P0^3;
  342. ; sbit lcdd1=P0^2;
  343. ; sbit lcdd2=P0^1;
  344. ; sbit lcdd3=P0^0;
  345. ; sbit lcdd4=P2^4;
  346. ; sbit lcdd5=P3^3;
  347. ; sbit lcdd6=P2^3;
  348. ; sbit lcdd7=P0^7;
  349. ;
  350. ; int volt,aolt,aolt_z,curr,mah;
  351. ; uchar key_flag=1;
  352. ; uchar num;
  353. ; uchar v_shi,v_ge,v_xiao1,v_xiao2;
  354. ; uchar a_shi,a_ge,a_xiao1,a_xiao2;
  355. ; uchar h_shi,h_ge,h_xiao1,h_xiao2;
  356. ; uchar t_shi,t_ge,t_xiao1,t_xiao2;
  357. ; uchar s,g,x1,x2;
  358. ; uchar data table[12]; //暂存数组,可以将10改为你需要的数值
  359. ; uint i=0;
  360. ; uchar code table1[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,};
  361. ; bit com_flag;
  362. ; uint time;
  363. ; uint num1,num2;
  364. ; bit time_flag;
  365. ; bit shan_flag;
  366. ; bit lcd_flag;
  367. ;
  368. ; void AD_init();
  369. ;
  370. ; // float AD_work(unsigned char channel);
  371. ;
  372. ; unsigned int AD_get(unsigned char channel);
  373. ; void delayms(uint z);
  374. ; void delay(unsigned int a); //延时约1ms
  375. ; void UART_init(void);               //初始化函数
  376. ; void senddata(uchar dat);
  377. ; void write_com(uchar com);
  378. ; void write_data(uchar date);
  379. ; void lcd_init();
  380. ; void time_init();
  381. ; void lcd_write_dat(uchar dat);
  382. ;
  383. ;
  384. ; void delayms(uint z)
  385.     RSEG  ?PR?_delayms?1602
  386. L?0071:
  387.     USING    0
  388. L?0072:
  389.     MOV      R7,#014H
  390.     MOV      R6,#00H
  391. _delayms:
  392.     USING    0
  393.             ; SOURCE LINE # 58
  394. ;---- Variable 'z?040' assigned to Register 'R6/R7' ----
  395. ; {
  396.             ; SOURCE LINE # 59
  397. ;         uint x,y;
  398. ;         for(x=z;x>0;x--)
  399.             ; SOURCE LINE # 61
  400. ;---- Variable 'x?041' assigned to Register 'R6/R7' ----
  401. ?C0001:
  402.     SETB     C
  403.     MOV      A,R7
  404.     SUBB     A,#00H
  405.     MOV      A,R6
  406.     SUBB     A,#00H
  407.     JC       ?C0007
  408. ;             for(y=110;y>0;y--);
  409.             ; SOURCE LINE # 62
  410. ;---- Variable 'y?042' assigned to Register 'R4/R5' ----
  411.     MOV      R5,#06EH
  412.     MOV      R4,#00H
  413. ?C0004:
  414.     MOV      A,R5
  415.     DEC      R5
  416.     JNZ      ?C0059
  417.     DEC      R4
  418. ?C0059:
  419.     MOV      A,R5
  420.     ORL      A,R4
  421.     JNZ      ?C0004
  422. ?C0003:
  423.     MOV      A,R7
  424.     DEC      R7
  425.     JNZ      ?C0001
  426.     DEC      R6
  427. ?C0060:
  428.     SJMP     ?C0001
  429. ; }      
  430.             ; SOURCE LINE # 63
  431. ?C0007:
  432.     RET      
  433. ; END OF _delayms
  434. ; /**********************************************************/
  435. ; void UART_init(void)               //初始化函 11.0592M
  436.     RSEG  ?PR?UART_init?1602
  437. UART_init:
  438.             ; SOURCE LINE # 65
  439. ; {
  440.             ; SOURCE LINE # 66
  441. ;     SCON = 0x50;
  442.             ; SOURCE LINE # 67
  443.     MOV      SCON,#050H
  444. ;     TMOD = 0x21;
  445.             ; SOURCE LINE # 68
  446.     MOV      TMOD,#021H
  447. ;     TH1  = 0xFD;                  //9600
  448.             ; SOURCE LINE # 69
  449.     MOV      TH1,#0FDH
  450. ;     TL1  = 0xFD;
  451.             ; SOURCE LINE # 70
  452.     MOV      TL1,#0FDH
  453. ;     TR1  = 1;
  454.             ; SOURCE LINE # 71
  455.     SETB     TR1
  456. ;     ES   = 1;
  457.             ; SOURCE LINE # 72
  458.     SETB     ES
  459. ;     EA   = 1;
  460.             ; SOURCE LINE # 73
  461.     SETB     EA
  462. ; }
  463.             ; SOURCE LINE # 74
  464.     RET      
  465. ; END OF UART_init
  466. ; /**********************************************************/
  467. ; void senddata(uchar dat)
  468.     RSEG  ?PR?_senddata?1602
  469. L?0073:
  470.     USING    0
  471. L?0074:
  472.     LCALL    _senddata
  473.     MOV      R7,#02CH
  474. _senddata:
  475.             ; SOURCE LINE # 76
  476. ;---- Variable 'dat?243' assigned to Register 'R7' ----
  477. ; {              
  478.             ; SOURCE LINE # 77
  479. ;
  480. ;     ES = 0;                       //关串口中断
  481.             ; SOURCE LINE # 79
  482.     CLR      ES
  483. ;     TI = 0;                       //将串口发送完成中断请求标志清零
  484.             ; SOURCE LINE # 80
  485.     CLR      TI
  486. ;     SBUF = dat;                //写数据到发送缓冲区
  487.             ; SOURCE LINE # 81
  488.     MOV      SBUF,R7
  489. ?C0009:
  490. ;     while(!TI);                   //等待发送完成
  491.             ; SOURCE LINE # 82
  492.     JNB      TI,?C0009
  493. ?C0010:
  494. ;     TI = 0;                       //将串口发送完成中断请求标志清零
  495.             ; SOURCE LINE # 83
  496.     CLR      TI
  497. ;     ES = 1;                   //将串口发送完成中断请求标志清零
  498.             ; SOURCE LINE # 84
  499.     SETB     ES
  500. ; }
  501.             ; SOURCE LINE # 85
  502.     RET      
  503. ; END OF _senddata
  504. ; /* ***************************************************** */
  505. ; void delay(unsigned int a) //延时约1ms
  506.     RSEG  ?PR?_delay?1602
  507. _delay:
  508.     USING    0
  509.             ; SOURCE LINE # 87
  510. ;---- Variable 'i?345' assigned to Register 'R4/R5' ----
  511. ;---- Variable 'a?344' assigned to Register 'R6/R7' ----
  512. ; {
  513.             ; SOURCE LINE # 88
  514. ?C0012:
  515. ;         unsigned int i;
  516. ;         while (--a!=0)
  517.             ; SOURCE LINE # 90
  518.     MOV      A,R7
  519.     DEC      R7
  520.     JNZ      ?C0061
  521.     DEC      R6
  522. ?C0061:
  523.     DEC      A
  524.     ORL      A,R6
  525.     JZ       ?C0017
  526. ;         for(i=600;i>0;i--);   //1T单片机i=600,若是12T单片机i=125
  527.             ; SOURCE LINE # 91
  528.     MOV      R4,#02H
  529.     MOV      R5,#058H
  530. ?C0014:
  531.     SETB     C
  532.     MOV      A,R5
  533.     SUBB     A,#00H
  534.     MOV      A,R4
  535.     SUBB     A,#00H
  536.     JC       ?C0012
  537.     MOV      A,R5
  538.     DEC      R5
  539.     JNZ      ?C0014
  540.     DEC      R4
  541. ?C0062:
  542.     SJMP     ?C0014
  543. ; }
  544.             ; SOURCE LINE # 92
  545. ?C0017:
  546.     RET      
  547. ; END OF _delay
  548. ;
  549. ; /*************************************************************/
  550. ;
  551. ; void lcd_write_dat(uchar dat)
  552.     RSEG  ?PR?_lcd_write_dat?1602
  553. _lcd_write_dat:
  554.     USING    0
  555.             ; SOURCE LINE # 96
  556.     MOV      dat?446,R7
  557. ; {
  558.             ; SOURCE LINE # 97
  559. ; #pragma asm
  560. ;     MOV A,R7
  561.       MOV A,R7
  562. ;     RRL A
  563.       RRL A
  564. ;     MOV lcdd0,C
  565.       MOV lcdd0,C
  566. ;     RRL A
  567.       RRL A
  568. ;     MOV lcdd1,C
  569.       MOV lcdd1,C
  570. ;     RRL A
  571.       RRL A
  572. ;     MOV lcdd2,C
  573.       MOV lcdd2,C
  574. ;     RRL A
  575.       RRL A
  576. ;     MOV lcdd3,C
  577.       MOV lcdd3,C
  578. ;     RRL A
  579.       RRL A
  580. ;     MOV lcdd4,C
  581.       MOV lcdd4,C
  582. ;     RRL A
  583.       RRL A
  584. ;     MOV lcdd5,C
  585.       MOV lcdd5,C
  586. ;     RRL A
  587.       RRL A
  588. ;     MOV lcdd6,C
  589.       MOV lcdd6,C
  590. ;     RRL A
  591.       RRL A
  592. ;     MOV lcdd7,C
  593.       MOV lcdd7,C
  594. ; #pragma endasm    
  595. ; }
  596.             ; SOURCE LINE # 117
  597.     RET      
  598. ; END OF _lcd_write_dat
  599. ;
  600. ;
  601. ;
  602. ;
  603. ; void write_com(uchar com)            //1602 lcd
  604.     RSEG  ?PR?_write_com?1602
  605. _write_com:
  606.     USING    0
  607.             ; SOURCE LINE # 122
  608. ;---- Variable 'com?547' assigned to Register 'R7' ----
  609. ; {
  610.             ; SOURCE LINE # 123
  611. ;     lcdrs=0;
  612.             ; SOURCE LINE # 124
  613.     CLR      lcdrs
  614. ;     lcden=1;
  615.             ; SOURCE LINE # 125
  616.     SETB     lcden
  617. ;         lcd_write_dat(com);
  618.             ; SOURCE LINE # 126
  619.     LCALL    _lcd_write_dat
  620. ;     delayms(5);
  621.             ; SOURCE LINE # 127
  622.     MOV      R7,#05H
  623.     MOV      R6,#00H
  624.     LCALL    _delayms
  625. ;     lcden=0;
  626.             ; SOURCE LINE # 128
  627.     CLR      lcden
  628. ; }
  629.             ; SOURCE LINE # 129
  630.     RET      
  631. ; END OF _write_com
  632. ; /**********************************************************/
  633. ; void write_data(uchar date)        //1602 lcd
  634.     RSEG  ?PR?_write_data?1602
  635. L?0069:
  636.     USING    0
  637. L?0070:
  638.     MOV      DPTR,#table1
  639.     MOVC     A,@A+DPTR
  640.     MOV      R7,A
  641. _write_data:
  642.     USING    0
  643.             ; SOURCE LINE # 131
  644. ;---- Variable 'date?648' assigned to Register 'R7' ----
  645. ; {
  646.             ; SOURCE LINE # 132
  647. ;     lcdrs=1;
  648.             ; SOURCE LINE # 133
  649.     SETB     lcdrs
  650. ;     lcden=1;
  651.             ; SOURCE LINE # 134
  652.     SETB     lcden
  653. ;     lcd_write_dat(date);
  654.             ; SOURCE LINE # 135
  655.     LCALL    _lcd_write_dat
  656. ;     delayms(5);
  657.             ; SOURCE LINE # 136
  658.     MOV      R7,#05H
  659.     MOV      R6,#00H
  660.     LCALL    _delayms
  661. ;     lcden=0;
  662.             ; SOURCE LINE # 137
  663.     CLR      lcden
  664. ; }
  665.             ; SOURCE LINE # 138
  666.     RET      
  667. ; END OF _write_data
  668. ; /**********************************************************/
  669. ; void lcd_init()    //lcd初始化
  670.     RSEG  ?PR?lcd_init?1602
  671. lcd_init:
  672.     USING    0
  673.             ; SOURCE LINE # 140
  674. ; {
  675.             ; SOURCE LINE # 141
  676. ;        lcdrw=0;
  677.             ; SOURCE LINE # 142
  678.     CLR      lcdrw
  679. ;      write_com(0x38);
  680.             ; SOURCE LINE # 143
  681.     MOV      R7,#038H
  682.     LCALL    _write_com
  683. ;      delayms(20);
  684.             ; SOURCE LINE # 144
  685.     LCALL    L?0071
  686. ;      write_com(0x38);
  687.             ; SOURCE LINE # 145
  688.     MOV      R7,#038H
  689.     LCALL    _write_com
  690. ;      delayms(20);
  691.             ; SOURCE LINE # 146
  692.     LCALL    L?0071
  693. ;             write_com(0x0c);
  694.             ; SOURCE LINE # 147
  695.     MOV      R7,#0CH
  696.     LCALL    _write_com
  697. ;      delayms(20);
  698.             ; SOURCE LINE # 148
  699.     LCALL    L?0072
  700. ;             write_com(0x06);
  701.             ; SOURCE LINE # 149
  702.     MOV      R7,#06H
  703.     LCALL    _write_com
  704. ;      delayms(20);
  705.             ; SOURCE LINE # 150
  706.     LCALL    L?0072
  707. ;             write_com(0x01);
  708.             ; SOURCE LINE # 151
  709.     MOV      R7,#01H
  710.     LCALL    _write_com
  711. ;      delayms(20);
  712.             ; SOURCE LINE # 152
  713.     MOV      R7,#014H
  714.     MOV      R6,#00H
  715.     LJMP     _delayms
  716. ; END OF lcd_init
  717. ; }
  718. ;
  719. ; void AD_init()
  720.     RSEG  ?PR?AD_init?1602
  721. AD_init:
  722.     USING    0
  723.             ; SOURCE LINE # 155
  724. ; {
  725.             ; SOURCE LINE # 156
  726. ;         P1ASF=0xa4; //p1.7 p1.2 p1.5作为模拟功能AD使用  0xc8  11001000   0x85  10000101
  727.             ; SOURCE LINE # 157
  728.     MOV      P1ASF,#0A4H
  729. ;         ADC_RES=0;   //清零转换结果寄存器高8位
  730.             ; SOURCE LINE # 158
  731.     CLR      A
  732.     MOV      ADC_RES,A
  733. ;         ADC_RESL=0; //清零转换结果寄存器低2位
  734.             ; SOURCE LINE # 159
  735.     MOV      ADC_RESL,A
  736. ;         ADC_CONTR=0x80;//开启AD电源
  737.             ; SOURCE LINE # 160
  738.     MOV      ADC_CONTR,#080H
  739. ;         delay(2);   //等待1ms,让AD电源稳定
  740.             ; SOURCE LINE # 161
  741.     MOV      R7,#02H
  742.     MOV      R6,A
  743.     LJMP     _delay
  744. ; END OF AD_init
  745. ; }
  746. ;
  747. ; void time_init()
  748.     RSEG  ?PR?time_init?1602
  749. time_init:
  750.             ; SOURCE LINE # 164
  751. ; {    
  752.             ; SOURCE LINE # 165
  753. ;         TH0=(65536-45872)/256;
  754.             ; SOURCE LINE # 166
  755.     MOV      TH0,#04CH
  756. ;         TL0=(65536-45872)%256;
  757.             ; SOURCE LINE # 167
  758.     MOV      TL0,#0D0H
  759. ;         EA=1;
  760.             ; SOURCE LINE # 168
  761.     SETB     EA
  762. ;         ET0=1;
  763.             ; SOURCE LINE # 169
  764.     SETB     ET0
  765. ;         TR0=1;
  766.             ; SOURCE LINE # 170
  767.     SETB     TR0
  768. ; }
  769.             ; SOURCE LINE # 171
  770.     RET      
  771. ; END OF time_init
  772. ;
  773. ; void lcd_display()
  774.     RSEG  ?PR?lcd_display?1602
  775. lcd_display:
  776.     USING    0
  777.             ; SOURCE LINE # 173
  778. ; {
  779.             ; SOURCE LINE # 174
  780. ; //             if (v_cd==0)  
  781. ; //         volt=AD_get(5)*2.49/AD_get(7)*977-(aolt*0.05);  //TL431    
  782. ; //          
  783. ; //             if (v_cd==1)  
  784. ; //         volt=AD_get(5)*2.49/AD_get(7)*977+(aolt*0.05);  //TL431
  785. ;    
  786. ;              volt=AD_get(5)*2.49/AD_get(7)*1001-(aolt*0.11);
  787.             ; SOURCE LINE # 181
  788.     MOV      R7,#05H
  789.     LCALL    _AD_get
  790.     MOV      R4,AR6
  791.     MOV      R5,AR7
  792.     CLR      A
  793.     LCALL    ?C?FCASTI
  794.     MOV      R3,#029H
  795.     MOV      R2,#05CH
  796.     MOV      R1,#01FH
  797.     MOV      R0,#040H
  798.     LCALL    ?C?FPMUL
  799.     PUSH     AR4
  800.     PUSH     AR5
  801.     PUSH     AR6
  802.     PUSH     AR7
  803.     MOV      R7,#07H
  804.     LCALL    _AD_get
  805.     MOV      R4,AR6
  806.     MOV      R5,AR7
  807.     CLR      A
  808.     LCALL    ?C?FCASTI
  809.     MOV      R0,AR4
  810.     MOV      R1,AR5
  811.     MOV      R2,AR6
  812.     MOV      R3,AR7
  813.     POP      AR7
  814.     POP      AR6
  815.     POP      AR5
  816.     POP      AR4
  817.     LCALL    ?C?FPDIV
  818.     MOV      R3,#00H
  819.     MOV      R2,#040H
  820.     MOV      R1,#07AH
  821.     MOV      R0,#044H
  822.     LCALL    ?C?FPMUL
  823.     PUSH     AR4
  824.     PUSH     AR5
  825.     PUSH     AR6
  826.     PUSH     AR7
  827.     MOV      R4,aolt
  828.     MOV      R5,aolt+01H
  829.     MOV      A,R4
  830.     LCALL    ?C?FCASTI
  831.     MOV      R3,#0AEH
  832.     MOV      R2,#047H
  833.     MOV      R1,#0E1H
  834.     MOV      R0,#03DH
  835.     LCALL    ?C?FPMUL
  836.     MOV      R0,AR4
  837.     MOV      R1,AR5
  838.     MOV      R2,AR6
  839.     MOV      R3,AR7
  840.     POP      AR7
  841.     POP      AR6
  842.     POP      AR5
  843.     POP      AR4
  844.     LCALL    ?C?FPSUB
  845.     LCALL    ?C?CASTF
  846.     MOV      volt,R6
  847.     MOV      volt+01H,R7
  848. ;                  
  849. ;         v_shi=volt/1000;    
  850.             ; SOURCE LINE # 183
  851.     MOV      R4,#03H
  852.     MOV      R5,#0E8H
  853.     LCALL    ?C?SIDIV
  854.     MOV      v_shi,R7
  855. ;         v_ge=volt%1000/100;      
  856.             ; SOURCE LINE # 184
  857.     MOV      R6,volt
  858.     MOV      R7,volt+01H
  859.     MOV      R4,#03H
  860.     MOV      R5,#0E8H
  861.     LCALL    ?C?SIDIV
  862.     MOV      R6,#00H
  863.     MOV      R7,#064H
  864.     XCH      A,R7
  865.     XCH      A,R5
  866.     XCH      A,R7
  867.     XCH      A,R6
  868.     XCH      A,R4
  869.     XCH      A,R6
  870.     LCALL    ?C?SIDIV
  871.     MOV      v_ge,R7
  872. ;         v_xiao1=volt%100/10;  
  873.             ; SOURCE LINE # 185
  874.     MOV      R6,volt
  875.     MOV      R7,volt+01H
  876.     MOV      R4,#00H
  877.     MOV      R5,#064H
  878.     LCALL    ?C?SIDIV
  879.     MOV      R6,#00H
  880.     MOV      R7,#0AH
  881.     XCH      A,R7
  882.     XCH      A,R5
  883.     XCH      A,R7
  884.     XCH      A,R6
  885.     XCH      A,R4
  886.     XCH      A,R6
  887.     LCALL    ?C?SIDIV
  888.     MOV      v_xiao1,R7
  889. ;         v_xiao2=volt%10;  
  890.             ; SOURCE LINE # 186
  891.     MOV      R6,volt
  892.     MOV      R7,volt+01H
  893.     MOV      R4,#00H
  894.     MOV      R5,#0AH
  895.     LCALL    ?C?SIDIV
  896.     MOV      v_xiao2,R5
  897. ;        
  898. ;         write_com(0x82);
  899.             ; SOURCE LINE # 188
  900.     MOV      R7,#082H
  901.     LCALL    _write_com
  902. ;         write_data(table1[v_shi]);
  903.             ; SOURCE LINE # 189
  904.     MOV      A,v_shi
  905.     LCALL    L?0069
  906. ;         write_com(0x83);
  907.             ; SOURCE LINE # 190
  908.     MOV      R7,#083H
  909.     LCALL    _write_com
  910. ;         write_data('.');
  911.             ; SOURCE LINE # 191
  912.     MOV      R7,#02EH
  913.     LCALL    _write_data
  914. ;         write_com(0x84);
  915.             ; SOURCE LINE # 192
  916.     MOV      R7,#084H
  917.     LCALL    _write_com
  918. ;         write_data(table1[v_ge]);
  919.             ; SOURCE LINE # 193
  920.     MOV      A,v_ge
  921.     LCALL    L?0069
  922. ;         write_com(0x85);
  923.             ; SOURCE LINE # 194
  924.     MOV      R7,#085H
  925.     LCALL    _write_com
  926. ;         write_data(table1[v_xiao1]);
  927.             ; SOURCE LINE # 195
  928.     MOV      A,v_xiao1
  929.     LCALL    L?0070
  930. ;         write_com(0x86);
  931.             ; SOURCE LINE # 196
  932.     MOV      R7,#086H
  933.     LCALL    _write_com
  934. ;  //       write_data(table1[v_xiao2]);          //小数点第三位显示
  935. ;         write_data(' ');                     //小数点第三位不显示
  936.             ; SOURCE LINE # 198
  937.     MOV      R7,#020H
  938.     LCALL    _write_data
  939. ;         write_com(0x87);
  940.             ; SOURCE LINE # 199
  941.     MOV      R7,#087H
  942.     LCALL    _write_com
  943. ;         write_data('V');
  944.             ; SOURCE LINE # 200
  945.     MOV      R7,#056H
  946.     LCALL    _write_data
  947. ;                
  948. ;                    
  949. ; //      aolt=AD_get(2)/AD_get(7)*1000; // 电流零位校准 显示1.000
  950. ;         aolt=((AD_get(2)*2.49)/AD_get(7)-2.48)*1020; // 电流计算公式
  951.             ; SOURCE LINE # 204
  952.     MOV      R7,#02H
  953.     LCALL    _AD_get
  954.     MOV      R4,AR6
  955.     MOV      R5,AR7
  956.     CLR      A
  957.     LCALL    ?C?FCASTI
  958.     MOV      R3,#029H
  959.     MOV      R2,#05CH
  960.     MOV      R1,#01FH
  961.     MOV      R0,#040H
  962.     LCALL    ?C?FPMUL
  963.     PUSH     AR4
  964.     PUSH     AR5
  965.     PUSH     AR6
  966.     PUSH     AR7
  967.     MOV      R7,#07H
  968.     LCALL    _AD_get
  969.     MOV      R4,AR6
  970.     MOV      R5,AR7
  971.     CLR      A
  972.     LCALL    ?C?FCASTI
  973.     MOV      R0,AR4
  974.     MOV      R1,AR5
  975.     MOV      R2,AR6
  976.     MOV      R3,AR7
  977.     POP      AR7
  978.     POP      AR6
  979.     POP      AR5
  980.     POP      AR4
  981.     LCALL    ?C?FPDIV
  982.     MOV      R3,#052H
  983.     MOV      R2,#0B8H
  984.     MOV      R1,#01EH
  985.     MOV      R0,#0C0H
  986.     LCALL    ?C?FPADD
  987.     CLR      A
  988.     MOV      R3,A
  989.     MOV      R2,A
  990.     MOV      R1,#07FH
  991.     MOV      R0,#044H
  992.     LCALL    ?C?FPMUL
  993.     LCALL    ?C?CASTF
  994.     MOV      aolt,R6
  995.     MOV      aolt+01H,R7
  996. ;   {     //充电电流为负,放电电流为正,负电流转正数
  997.             ; SOURCE LINE # 205
  998. ;         if (aolt < 0)  
  999.             ; SOURCE LINE # 206
  1000.     CLR      C
  1001.     MOV      A,aolt
  1002.     XRL      A,#080H
  1003.     SUBB     A,#080H
  1004.     JNC      ?C0024
  1005. ;         {  
  1006.             ; SOURCE LINE # 207
  1007. ;                 aolt_z =aolt*-1;  
  1008.             ; SOURCE LINE # 208
  1009.     MOV      R4,#0FFH
  1010.     MOV      R5,#0FFH
  1011.     LCALL    ?C?IMUL
  1012.     MOV      aolt_z,R6
  1013.     MOV      aolt_z+01H,R7
  1014. ;         }  
  1015.             ; SOURCE LINE # 209
  1016.     SJMP     ?C0025
  1017. ?C0024:
  1018. ;         else
  1019. ;                 aolt_z =aolt*1;  
  1020.             ; SOURCE LINE # 211
  1021.     MOV      aolt_z,aolt
  1022.     MOV      aolt_z+01H,aolt+01H
  1023. ?C0025:
  1024. ;   }  
  1025.             ; SOURCE LINE # 212
  1026. ;         a_shi=aolt_z/1000;
  1027.             ; SOURCE LINE # 213
  1028.     MOV      R6,aolt_z
  1029.     MOV      R7,aolt_z+01H
  1030.     MOV      R4,#03H
  1031.     MOV      R5,#0E8H
  1032.     LCALL    ?C?SIDIV
  1033.     MOV      a_shi,R7
  1034. ;         a_ge=aolt_z%1000/100;
  1035.             ; SOURCE LINE # 214
  1036.     MOV      R6,aolt_z
  1037.     MOV      R7,aolt_z+01H
  1038.     MOV      R4,#03H
  1039.     MOV      R5,#0E8H
  1040.     LCALL    ?C?SIDIV
  1041.     MOV      R6,#00H
  1042.     MOV      R7,#064H
  1043.     XCH      A,R7
  1044.     XCH      A,R5
  1045.     XCH      A,R7
  1046.     XCH      A,R6
  1047.     XCH      A,R4
  1048.     XCH      A,R6
  1049.     LCALL    ?C?SIDIV
  1050.     MOV      a_ge,R7
  1051. ;         a_xiao1=aolt_z%100/10;
  1052.             ; SOURCE LINE # 215
  1053.     MOV      R6,aolt_z
  1054.     MOV      R7,aolt_z+01H
  1055.     MOV      R4,#00H
  1056.     MOV      R5,#064H
  1057.     LCALL    ?C?SIDIV
  1058.     MOV      R6,#00H
  1059.     MOV      R7,#0AH
  1060.     XCH      A,R7
  1061.     XCH      A,R5
  1062.     XCH      A,R7
  1063.     XCH      A,R6
  1064.     XCH      A,R4
  1065.     XCH      A,R6
  1066.     LCALL    ?C?SIDIV
  1067.     MOV      a_xiao1,R7
  1068. ;         a_xiao2=aolt_z%10;
  1069.             ; SOURCE LINE # 216
  1070.     MOV      R6,aolt_z
  1071.     MOV      R7,aolt_z+01H
  1072.     MOV      R4,#00H
  1073.     MOV      R5,#0AH
  1074.     LCALL    ?C?SIDIV
  1075.     MOV      a_xiao2,R5
  1076. ;        
  1077. ;         write_com(0x89);
  1078.             ; SOURCE LINE # 218
  1079.     MOV      R7,#089H
  1080.     LCALL    _write_com
  1081. ;         write_data(table1[a_shi]);
  1082.             ; SOURCE LINE # 219
  1083.     MOV      A,a_shi
  1084.     LCALL    L?0070
  1085. ;         write_com(0x8a);
  1086.             ; SOURCE LINE # 220
  1087.     MOV      R7,#08AH
  1088.     LCALL    _write_com
  1089. ;         write_data('.');
  1090.             ; SOURCE LINE # 221
  1091.     MOV      R7,#02EH
  1092.     LCALL    _write_data
  1093. ;         write_com(0x8b);
  1094.             ; SOURCE LINE # 222
  1095.     MOV      R7,#08BH
  1096.     LCALL    _write_com
  1097. ;         write_data(table1[a_ge]);
  1098.             ; SOURCE LINE # 223
  1099.     MOV      A,a_ge
  1100.     LCALL    L?0070
  1101. ;         write_com(0x8c);
  1102.             ; SOURCE LINE # 224
  1103.     MOV      R7,#08CH
  1104.     LCALL    _write_com
  1105. ;         write_data(table1[a_xiao1]);
  1106.             ; SOURCE LINE # 225
  1107.     MOV      A,a_xiao1
  1108.     LCALL    L?0070
  1109. ;         write_com(0x8d);
  1110.             ; SOURCE LINE # 226
  1111.     MOV      R7,#08DH
  1112.     LCALL    _write_com
  1113. ;  //        write_data(table1[a_xiao2]);  //小数点第三位显示
  1114. ;           write_data(' ');                 //小数点第三位不显示
  1115.             ; SOURCE LINE # 228
  1116.     MOV      R7,#020H
  1117.     LCALL    _write_data
  1118. ;         write_com(0x8e);
  1119.             ; SOURCE LINE # 229
  1120.     MOV      R7,#08EH
  1121.     LCALL    _write_com
  1122. ;         write_data('A');    
  1123.             ; SOURCE LINE # 230
  1124.     MOV      R7,#041H
  1125.     LCALL    _write_data
  1126. ;         write_com(0xC0);    
  1127.             ; SOURCE LINE # 231
  1128.     MOV      R7,#0C0H
  1129.     LCALL    _write_com
  1130. ;         write_data(' ');
  1131.             ; SOURCE LINE # 232
  1132.     MOV      R7,#020H
  1133.     LCALL    _write_data
  1134. ;        
  1135. ;         h_shi=mah/1000;
  1136.             ; SOURCE LINE # 234
  1137.     MOV      R6,mah
  1138.     MOV      R7,mah+01H
  1139.     MOV      R4,#03H
  1140.     MOV      R5,#0E8H
  1141.     LCALL    ?C?SIDIV
  1142.     MOV      h_shi,R7
  1143. ;         h_ge=mah%1000/100;
  1144.             ; SOURCE LINE # 235
  1145.     MOV      R6,mah
  1146.     MOV      R7,mah+01H
  1147.     MOV      R4,#03H
  1148.     MOV      R5,#0E8H
  1149.     LCALL    ?C?SIDIV
  1150.     MOV      R6,#00H
  1151.     MOV      R7,#064H
  1152.     XCH      A,R7
  1153.     XCH      A,R5
  1154.     XCH      A,R7
  1155.     XCH      A,R6
  1156.     XCH      A,R4
  1157.     XCH      A,R6
  1158.     LCALL    ?C?SIDIV
  1159.     MOV      h_ge,R7
  1160. ;         h_xiao1=mah%100/10;
  1161.             ; SOURCE LINE # 236
  1162.     MOV      R6,mah
  1163.     MOV      R7,mah+01H
  1164.     MOV      R4,#00H
  1165.     MOV      R5,#064H
  1166.     LCALL    ?C?SIDIV
  1167.     MOV      R6,#00H
  1168.     MOV      R7,#0AH
  1169.     XCH      A,R7
  1170.     XCH      A,R5
  1171.     XCH      A,R7
  1172.     XCH      A,R6
  1173.     XCH      A,R4
  1174.     XCH      A,R6
  1175.     LCALL    ?C?SIDIV
  1176.     MOV      h_xiao1,R7
  1177. ;         h_xiao2=mah%10;
  1178.             ; SOURCE LINE # 237
  1179.     MOV      R6,mah
  1180.     MOV      R7,mah+01H
  1181.     MOV      R4,#00H
  1182.     MOV      R5,#0AH
  1183.     LCALL    ?C?SIDIV
  1184.     MOV      h_xiao2,R5
  1185. ;    
  1186. ;         write_com(0xc1);
  1187.             ; SOURCE LINE # 239
  1188.     MOV      R7,#0C1H
  1189.     LCALL    _write_com
  1190. ;         write_data(table1[h_shi]);
  1191.             ; SOURCE LINE # 240
  1192.     MOV      A,h_shi
  1193.     LCALL    L?0070
  1194. ;         write_com(0xc2);
  1195.             ; SOURCE LINE # 241
  1196.     MOV      R7,#0C2H
  1197.     LCALL    _write_com
  1198. ;         write_data(table1[h_ge]);
  1199.             ; SOURCE LINE # 242
  1200.     MOV      A,h_ge
  1201.     LCALL    L?0070
  1202. ;         write_com(0xc3);
  1203.             ; SOURCE LINE # 243
  1204.     MOV      R7,#0C3H
  1205.     LCALL    _write_com
  1206. ;         write_data(table1[h_xiao1]);
  1207.             ; SOURCE LINE # 244
  1208.     MOV      A,h_xiao1
  1209.     LCALL    L?0070
  1210. ;         write_com(0xc4);
  1211.             ; SOURCE LINE # 245
  1212.     MOV      R7,#0C4H
  1213.     LCALL    _write_com
  1214. ;         write_data(table1[h_xiao2]);
  1215.             ; SOURCE LINE # 246
  1216.     MOV      A,h_xiao2
  1217.     LCALL    L?0070
  1218. ;         write_com(0xc5);
  1219.             ; SOURCE LINE # 247
  1220.     MOV      R7,#0C5H
  1221.     LCALL    _write_com
  1222. ;         write_data('m');
  1223.             ; SOURCE LINE # 248
  1224.     MOV      R7,#06DH
  1225.     LCALL    _write_data
  1226. ;         write_com(0xc6);
  1227.             ; SOURCE LINE # 249
  1228.     MOV      R7,#0C6H
  1229.     LCALL    _write_com
  1230. ;         write_data('A');
  1231.             ; SOURCE LINE # 250
  1232.     MOV      R7,#041H
  1233.     LCALL    _write_data
  1234. ;         write_com(0xc7);
  1235.             ; SOURCE LINE # 251
  1236.     MOV      R7,#0C7H
  1237.     LCALL    _write_com
  1238. ;         write_data('h');
  1239.             ; SOURCE LINE # 252
  1240.     MOV      R7,#068H
  1241.     LCALL    _write_data
  1242. ;         write_com(0xc8);
  1243.             ; SOURCE LINE # 253
  1244.     MOV      R7,#0C8H
  1245.     LCALL    _write_com
  1246. ;         write_data(' ');
  1247.             ; SOURCE LINE # 254
  1248.     MOV      R7,#020H
  1249.     LCALL    _write_data
  1250. ;         write_com(0xc9);
  1251.             ; SOURCE LINE # 255
  1252.     MOV      R7,#0C9H
  1253.     LCALL    _write_com
  1254. ;         write_data('T');
  1255.             ; SOURCE LINE # 256
  1256.     MOV      R7,#054H
  1257.     LCALL    _write_data
  1258. ;         write_com(0xca);
  1259.             ; SOURCE LINE # 257
  1260.     MOV      R7,#0CAH
  1261.     LCALL    _write_com
  1262. ;         write_data('=');
  1263.             ; SOURCE LINE # 258
  1264.     MOV      R7,#03DH
  1265.     LCALL    _write_data
  1266. ;         t_shi=time/100;
  1267.             ; SOURCE LINE # 259
  1268.     MOV      R6,time
  1269.     MOV      R7,time+01H
  1270.     MOV      R4,#00H
  1271.     MOV      R5,#064H
  1272.     LCALL    ?C?UIDIV
  1273.     MOV      t_shi,R7
  1274. ;         t_ge=time%100/10;
  1275.             ; SOURCE LINE # 260
  1276.     MOV      R6,time
  1277.     MOV      R7,time+01H
  1278.     MOV      R4,#00H
  1279.     MOV      R5,#064H
  1280.     LCALL    ?C?UIDIV
  1281.     MOV      R6,#00H
  1282.     MOV      R7,#0AH
  1283.     XCH      A,R7
  1284.     XCH      A,R5
  1285.     XCH      A,R7
  1286.     XCH      A,R6
  1287.     XCH      A,R4
  1288.     XCH      A,R6
  1289.     LCALL    ?C?UIDIV
  1290.     MOV      t_ge,R7
  1291. ;         t_xiao1=time%10;
  1292.             ; SOURCE LINE # 261
  1293.     MOV      R6,time
  1294.     MOV      R7,time+01H
  1295.     MOV      R4,#00H
  1296.     MOV      R5,#0AH
  1297.     LCALL    ?C?UIDIV
  1298.     MOV      t_xiao1,R5
  1299. ;         write_com(0xcb);
  1300.             ; SOURCE LINE # 262
  1301.     MOV      R7,#0CBH
  1302.     LCALL    _write_com
  1303. ;         write_data(table1[t_shi]);
  1304.             ; SOURCE LINE # 263
  1305.     MOV      A,t_shi
  1306.     LCALL    L?0070
  1307. ;         write_com(0xcc);
  1308.             ; SOURCE LINE # 264
  1309.     MOV      R7,#0CCH
  1310.     LCALL    _write_com
  1311. ;         write_data(table1[t_ge]);
  1312.             ; SOURCE LINE # 265
  1313.     MOV      A,t_ge
  1314.     LCALL    L?0070
  1315. ;         write_com(0xcd);
  1316.             ; SOURCE LINE # 266
  1317.     MOV      R7,#0CDH
  1318.     LCALL    _write_com
  1319. ;         write_data(table1[t_xiao1]);
  1320.             ; SOURCE LINE # 267
  1321.     MOV      A,t_xiao1
  1322.     LCALL    L?0070
  1323. ;         write_com(0xce);
  1324.             ; SOURCE LINE # 268
  1325.     MOV      R7,#0CEH
  1326.     LCALL    _write_com
  1327. ;         write_data('M');
  1328.             ; SOURCE LINE # 269
  1329.     MOV      R7,#04DH
  1330.     LJMP     _write_data
  1331. ; END OF lcd_display
  1332. ; }
  1333. ;
  1334. ; void keysean()
  1335.     RSEG  ?PR?keysean?1602
  1336. keysean:
  1337.     USING    0
  1338.             ; SOURCE LINE # 272
  1339. ; {
  1340.             ; SOURCE LINE # 273
  1341. ;         if(key==0)
  1342.             ; SOURCE LINE # 274
  1343.     JB       key,?C0027
  1344. ;         {
  1345.             ; SOURCE LINE # 275
  1346. ;                 delayms(500);
  1347.             ; SOURCE LINE # 276
  1348.     MOV      R7,#0F4H
  1349.     MOV      R6,#01H
  1350.     LCALL    _delayms
  1351. ;                 if(key==0)
  1352.             ; SOURCE LINE # 277
  1353.     JB       key,?C0030
  1354. ;                 {
  1355.             ; SOURCE LINE # 278
  1356. ;                     key_flag++;
  1357.             ; SOURCE LINE # 279
  1358.     INC      key_flag
  1359. ;                  if(key_flag>3)
  1360.             ; SOURCE LINE # 280
  1361.     MOV      A,key_flag
  1362.     SETB     C
  1363.     SUBB     A,#03H
  1364.     JC       ?C0030
  1365. ;                     key_flag=1;
  1366.             ; SOURCE LINE # 281
  1367.     MOV      key_flag,#01H
  1368. ;                 }
  1369.             ; SOURCE LINE # 282
  1370. ?C0030:
  1371. ;                 while(!key);
  1372.             ; SOURCE LINE # 283
  1373.     JNB      key,?C0030
  1374. ?C0031:
  1375. ;         }
  1376.             ; SOURCE LINE # 284
  1377. ?C0027:
  1378. ;        
  1379. ;             if(key_flag==1)
  1380.             ; SOURCE LINE # 286
  1381.     MOV      A,key_flag
  1382.     CJNE     A,#01H,?C0032
  1383. ;             {
  1384.             ; SOURCE LINE # 287
  1385. ;                     v_fd=1;
  1386.             ; SOURCE LINE # 288
  1387.     SETB     v_fd
  1388. ;                     v_cd=1;
  1389.             ; SOURCE LINE # 289
  1390.     SETB     v_cd
  1391. ;                            
  1392. ;                     write_com(0x80);
  1393.             ; SOURCE LINE # 291
  1394.     MOV      R7,#080H
  1395.     LCALL    _write_com
  1396. ;                     write_data('=');
  1397.             ; SOURCE LINE # 292
  1398.     MOV      R7,#03DH
  1399.     LCALL    _write_data
  1400. ;                                   write_com(0x81);
  1401.             ; SOURCE LINE # 293
  1402.     MOV      R7,#081H
  1403.     LCALL    _write_com
  1404. ;                     write_data(' ');
  1405.             ; SOURCE LINE # 294
  1406.     MOV      R7,#020H
  1407.     LCALL    _write_data
  1408. ;                     num1=0;
  1409.             ; SOURCE LINE # 295
  1410.     CLR      A
  1411.     MOV      num1,A
  1412.     MOV      num1+01H,A
  1413. ;                     time_flag=0;
  1414.             ; SOURCE LINE # 296
  1415.     CLR      time_flag
  1416. ;             }
  1417.             ; SOURCE LINE # 297
  1418. ?C0032:
  1419. ;            
  1420. ;             if(key_flag==2)
  1421.             ; SOURCE LINE # 299
  1422.     MOV      A,key_flag
  1423.     CJNE     A,#02H,?C0033
  1424. ;             {
  1425.             ; SOURCE LINE # 300
  1426. ;                     v_fd=1;
  1427.             ; SOURCE LINE # 301
  1428.     SETB     v_fd
  1429. ;                     v_cd=0;
  1430.             ; SOURCE LINE # 302
  1431.     CLR      v_cd
  1432. ;                    
  1433. ;                                 time=0;    
  1434.             ; SOURCE LINE # 304
  1435.     CLR      A
  1436.     MOV      time,A
  1437.     MOV      time+01H,A
  1438. ;                     mah=0;                
  1439.             ; SOURCE LINE # 305
  1440.     MOV      mah,A
  1441.     MOV      mah+01H,A
  1442. ;                
  1443. ;                 write_com(0x80);
  1444.             ; SOURCE LINE # 307
  1445.     MOV      R7,#080H
  1446.     LCALL    _write_com
  1447. ;                 write_data('C');
  1448.             ; SOURCE LINE # 308
  1449.     MOV      R7,#043H
  1450.     LCALL    _write_data
  1451. ;                 write_com(0x81);
  1452.             ; SOURCE LINE # 309
  1453.     MOV      R7,#081H
  1454.     LCALL    _write_com
  1455. ;                 write_data('D');
  1456.             ; SOURCE LINE # 310
  1457.     MOV      R7,#044H
  1458.     LCALL    _write_data
  1459. ;             }
  1460.             ; SOURCE LINE # 311
  1461. ?C0033:
  1462. ;            
  1463. ;             if(key_flag==3)
  1464.             ; SOURCE LINE # 313
  1465.     MOV      A,key_flag
  1466.     XRL      A,#03H
  1467.     JNZ      ?C0037
  1468. ;             {
  1469.             ; SOURCE LINE # 314
  1470. ;                     v_cd=1;
  1471.             ; SOURCE LINE # 315
  1472.     SETB     v_cd
  1473. ;                     v_fd=0;
  1474.             ; SOURCE LINE # 316
  1475.     CLR      v_fd
  1476. ;                     time_flag=1;    //放电计时开关  1有效
  1477.             ; SOURCE LINE # 317
  1478.     SETB     time_flag
  1479. ;                     if(shan_flag==0)
  1480.             ; SOURCE LINE # 318
  1481.     JB       shan_flag,?C0035
  1482. ;                     {
  1483.             ; SOURCE LINE # 319
  1484. ;                             write_com(0x80);
  1485.             ; SOURCE LINE # 320
  1486.     MOV      R7,#080H
  1487.     LCALL    _write_com
  1488. ;                             write_data('F');
  1489.             ; SOURCE LINE # 321
  1490.     MOV      R7,#046H
  1491.     LCALL    _write_data
  1492. ;                                                   write_com(0x81);
  1493.             ; SOURCE LINE # 322
  1494.     MOV      R7,#081H
  1495.     LCALL    _write_com
  1496. ;                             write_data('D');
  1497.             ; SOURCE LINE # 323
  1498.     MOV      R7,#044H
  1499.     LCALL    _write_data
  1500. ;                     }
  1501.             ; SOURCE LINE # 324
  1502. ?C0035:
  1503. ;                     if(v_shi==2 && v_ge==8)
  1504.             ; SOURCE LINE # 325
  1505.     MOV      A,v_shi
  1506.     CJNE     A,#02H,?C0037
  1507.     MOV      A,v_ge
  1508.     CJNE     A,#08H,?C0037
  1509. ;                     {
  1510.             ; SOURCE LINE # 326
  1511. ;                             v_fd=1;
  1512.             ; SOURCE LINE # 327
  1513.     SETB     v_fd
  1514. ;                             v_cd=1;
  1515.             ; SOURCE LINE # 328
  1516.     SETB     v_cd
  1517. ;                             time_flag=0;
  1518.             ; SOURCE LINE # 329
  1519.     CLR      time_flag
  1520. ;                             key_flag=1;
  1521.             ; SOURCE LINE # 330
  1522.     MOV      key_flag,#01H
  1523. ;                     }
  1524.             ; SOURCE LINE # 331
  1525. ;             }
  1526.             ; SOURCE LINE # 332
  1527. ; }
  1528.             ; SOURCE LINE # 333
  1529. ?C0037:
  1530.     RET      
  1531. ; END OF keysean
  1532. ;
  1533. ; unsigned int AD_get(unsigned char channel)
  1534.     RSEG  ?PR?_AD_get?1602
  1535. _AD_get:
  1536.     USING    0
  1537.             ; SOURCE LINE # 335
  1538. ;---- Variable 'channel?1249' assigned to Register 'R7' ----
  1539. ; {
  1540.             ; SOURCE LINE # 336
  1541. ;         ADC_CONTR=0x88|channel;    //开启AD转换1000 1000 即POWER SPEED1 SPEED0 ADC_FLAG   ADC_START CHS2 CHS1 CHS0 ADC_CONTR=0x88|channel;    
  1542.             ; SOURCE LINE # 337
  1543.     MOV      A,R7
  1544.     ORL      A,#088H
  1545.     MOV      ADC_CONTR,A
  1546. ;         _nop_(); _nop_(); _nop_(); _nop_();//要经过4个CPU时钟的延时,其值才能够保证被设置进ADC_CONTR 寄存器
  1547.             ; SOURCE LINE # 338
  1548.     NOP      
  1549.     NOP      
  1550.     NOP      
  1551.     NOP      
  1552. ?C0038:
  1553. ;         while(!(ADC_CONTR&0x10));    //等待转换完成
  1554.             ; SOURCE LINE # 339
  1555.     MOV      A,ADC_CONTR
  1556.     JNB      ACC.4,?C0038
  1557. ?C0039:
  1558. ;         ADC_CONTR&=0xe7;      //关闭AD转换,ADC_FLAG位由软件清0
  1559.             ; SOURCE LINE # 340
  1560.     ANL      ADC_CONTR,#0E7H
  1561. ;         return(ADC_RES*4+ADC_RESL);   //返回AD转换完成的10位数据(16进制)
  1562.             ; SOURCE LINE # 341
  1563.     MOV      R7,ADC_RES
  1564.     MOV      A,R7
  1565.     MOV      B,#04H
  1566.     MUL      AB
  1567.     MOV      R5,ADC_RESL
  1568.     MOV      R4,#00H
  1569.     ADD      A,R5
  1570.     MOV      R7,A
  1571.     MOV      A,R4
  1572.     ADDC     A,B
  1573.     MOV      R6,A
  1574. ; }
  1575.             ; SOURCE LINE # 342
  1576. ?C0040:
  1577.     RET      
  1578. ; END OF _AD_get
  1579. ; void main()
  1580.     RSEG  ?PR?main?1602
  1581. main:
  1582.     USING    0
  1583.             ; SOURCE LINE # 343
  1584. ; {    
  1585.             ; SOURCE LINE # 344
  1586. ;         AD_init();
  1587.             ; SOURCE LINE # 345
  1588.     LCALL    AD_init
  1589. ;         UART_init();
  1590.             ; SOURCE LINE # 346
  1591.     LCALL    UART_init
  1592. ;           lcd_init();  
  1593.             ; SOURCE LINE # 347
  1594.     LCALL    lcd_init
  1595. ;         time_init();
  1596.             ; SOURCE LINE # 348
  1597.     LCALL    time_init
  1598. ;           v_cd=1;
  1599.             ; SOURCE LINE # 349
  1600.     SETB     v_cd
  1601. ;         v_fd=1;
  1602.             ; SOURCE LINE # 350
  1603.     SETB     v_fd
  1604. ?C0041:
  1605. ;        
  1606. ;         while(1)
  1607.             ; SOURCE LINE # 352
  1608. ;         {
  1609.             ; SOURCE LINE # 353
  1610. ;                 if(com_flag==0)      //      
  1611.             ; SOURCE LINE # 354
  1612.     JB       com_flag,?C0043
  1613. ;                 keysean();
  1614.             ; SOURCE LINE # 355
  1615.     LCALL    keysean
  1616. ?C0043:
  1617. ;                 if(lcd_flag==1)
  1618.             ; SOURCE LINE # 356
  1619.     JNB      lcd_flag,?C0041
  1620. ;                 {
  1621.             ; SOURCE LINE # 357
  1622. ;                     lcd_display();
  1623.             ; SOURCE LINE # 358
  1624.     LCALL    lcd_display
  1625. ;                     lcd_flag=0;
  1626.             ; SOURCE LINE # 359
  1627.     CLR      lcd_flag
  1628. ;                 }
  1629.             ; SOURCE LINE # 360
  1630. ;         }
  1631.             ; SOURCE LINE # 361
  1632.     SJMP     ?C0041
  1633. ; END OF main
  1634. CSEG    AT    00023H
  1635.     LJMP    interrupt_uart
  1636. ; }
  1637. ;
  1638. ; void interrupt_uart() interrupt 4
  1639.     RSEG  ?PR?interrupt_uart?1602
  1640.     USING    0
  1641. interrupt_uart:
  1642.     PUSH     ACC
  1643.     PUSH     DPH
  1644.     PUSH     DPL
  1645.     PUSH     PSW
  1646.     MOV      PSW,#00H
  1647.     PUSH     AR0
  1648.     PUSH     AR7
  1649.     USING    0
  1650.             ; SOURCE LINE # 364
  1651. ; {
  1652. ;           ES=0;    //关串口中断
  1653.             ; SOURCE LINE # 366
  1654.     CLR      ES
  1655. ;           table[i]=SBUF;//命令存到命令数组
  1656.             ; SOURCE LINE # 367
  1657.     MOV      A,#LOW (table)
  1658.     ADD      A,i+01H
  1659.     MOV      R0,A
  1660.     MOV      @R0,SBUF
  1661. ;             if(table[0]=='W')
  1662.             ; SOURCE LINE # 368
  1663.     MOV      A,table
  1664.     CJNE     A,#057H,?C0046
  1665. ;             i++;
  1666.             ; SOURCE LINE # 369
  1667.     INC      i+01H
  1668.     MOV      A,i+01H
  1669.     JNZ      ?C0047
  1670.     INC      i
  1671. ?C0063:
  1672.     SJMP     ?C0047
  1673. ?C0046:
  1674. ;             else
  1675. ;             i=0;
  1676.             ; SOURCE LINE # 371
  1677.     MOV      i,#00H
  1678.     MOV      i+01H,#00H
  1679. ?C0047:
  1680. ;             RI=0; //软件清除接收中断
  1681.             ; SOURCE LINE # 372
  1682.     CLR      RI
  1683. ;             ES=1;//开串口中断
  1684.             ; SOURCE LINE # 373
  1685.     SETB     ES
  1686. ;         if(i>8)      //如果接受字节大于8个开始检测接受字节后四位数据  Work_v_ad
  1687.             ; SOURCE LINE # 374
  1688.     SETB     C
  1689.     MOV      A,i+01H
  1690.     SUBB     A,#08H
  1691.     MOV      A,i
  1692.     SUBB     A,#00H
  1693.     JNC      $ + 5H
  1694.     LJMP     ?C0053
  1695. ;     {
  1696.             ; SOURCE LINE # 375
  1697. ;                 if(table[5]=='v'&&table[6]=='_'&&table[7]=='a'&&table[8]=='d')
  1698.             ; SOURCE LINE # 376
  1699.     MOV      A,table+05H
  1700.     XRL      A,#076H
  1701.     JZ       $ + 5H
  1702.     LJMP     ?C0049
  1703.     MOV      A,table+06H
  1704.     XRL      A,#05FH
  1705.     JZ       $ + 5H
  1706.     LJMP     ?C0049
  1707.     MOV      A,table+07H
  1708.     XRL      A,#061H
  1709.     JZ       $ + 5H
  1710.     LJMP     ?C0049
  1711.     MOV      A,table+08H
  1712.     XRL      A,#064H
  1713.     JZ       $ + 5H
  1714.     LJMP     ?C0049
  1715. ;         {  
  1716.             ; SOURCE LINE # 377
  1717. ;                         senddata(table1[v_shi]);
  1718.             ; SOURCE LINE # 378
  1719.     MOV      A,v_shi
  1720.     MOV      DPTR,#table1
  1721.     MOVC     A,@A+DPTR
  1722.     MOV      R7,A
  1723.     LCALL    _senddata
  1724. ;                         senddata('.');
  1725.             ; SOURCE LINE # 379
  1726.     MOV      R7,#02EH
  1727.     LCALL    _senddata
  1728. ;                         senddata(table1[v_ge]);
  1729.             ; SOURCE LINE # 380
  1730.     MOV      A,v_ge
  1731.     MOVC     A,@A+DPTR
  1732.     MOV      R7,A
  1733.     LCALL    _senddata
  1734. ;                         senddata(table1[v_xiao1]);
  1735.             ; SOURCE LINE # 381
  1736.     MOV      A,v_xiao1
  1737.     MOVC     A,@A+DPTR
  1738.     MOV      R7,A
  1739.     LCALL    _senddata
  1740. ;                         senddata(table1[v_xiao2]);
  1741.             ; SOURCE LINE # 382
  1742.     MOV      A,v_xiao2
  1743.     MOVC     A,@A+DPTR
  1744.     MOV      R7,A
  1745.     LCALL    _senddata
  1746. ;                         senddata('V');
  1747.             ; SOURCE LINE # 383
  1748.     MOV      R7,#056H
  1749. ;                         senddata(',');
  1750.             ; SOURCE LINE # 384
  1751.     LCALL    L?0073
  1752. ;                         senddata(table1[a_shi]);
  1753.             ; SOURCE LINE # 385
  1754.     MOV      A,a_shi
  1755.     MOVC     A,@A+DPTR
  1756.     MOV      R7,A
  1757.     LCALL    _senddata
  1758. ;                         senddata('.');
  1759.             ; SOURCE LINE # 386
  1760.     MOV      R7,#02EH
  1761.     LCALL    _senddata
  1762. ;                         senddata(table1[a_ge]);
  1763.             ; SOURCE LINE # 387
  1764.     MOV      A,a_ge
  1765.     MOVC     A,@A+DPTR
  1766.     MOV      R7,A
  1767.     LCALL    _senddata
  1768. ;                         senddata(table1[a_xiao1]);
  1769.             ; SOURCE LINE # 388
  1770.     MOV      A,a_xiao1
  1771.     MOVC     A,@A+DPTR
  1772.     MOV      R7,A
  1773.     LCALL    _senddata
  1774. ;                         senddata(table1[a_xiao2]);
  1775.             ; SOURCE LINE # 389
  1776.     MOV      A,a_xiao2
  1777.     MOVC     A,@A+DPTR
  1778.     MOV      R7,A
  1779.     LCALL    _senddata
  1780. ;                         senddata('A');
  1781.             ; SOURCE LINE # 390
  1782.     MOV      R7,#041H
  1783. ; //*****************串口新增容量时间输出
  1784. ; senddata(',');
  1785.             ; SOURCE LINE # 392
  1786.     LCALL    L?0073
  1787. ; senddata(table1[h_shi]);                  
  1788.             ; SOURCE LINE # 393
  1789.     MOV      A,h_shi
  1790.     MOVC     A,@A+DPTR
  1791.     MOV      R7,A
  1792.     LCALL    _senddata
  1793. ; senddata(table1[h_ge]);
  1794.             ; SOURCE LINE # 394
  1795.     MOV      A,h_ge
  1796.     MOVC     A,@A+DPTR
  1797.     MOV      R7,A
  1798.     LCALL    _senddata
  1799. ; senddata(table1[h_xiao1]);        
  1800.             ; SOURCE LINE # 395
  1801.     MOV      A,h_xiao1
  1802.     MOVC     A,@A+DPTR
  1803.     MOV      R7,A
  1804.     LCALL    _senddata
  1805. ; senddata(table1[h_xiao2]);
  1806.             ; SOURCE LINE # 396
  1807.     MOV      A,h_xiao2
  1808.     MOVC     A,@A+DPTR
  1809.     MOV      R7,A
  1810. ; senddata(',');
  1811.             ; SOURCE LINE # 397
  1812.     LCALL    L?0074
  1813. ; senddata(table1[t_shi]);
  1814.             ; SOURCE LINE # 398
  1815.     MOV      A,t_shi
  1816.     MOVC     A,@A+DPTR
  1817.     MOV      R7,A
  1818.     LCALL    _senddata
  1819. ; senddata(table1[t_ge]);
  1820.             ; SOURCE LINE # 399
  1821.     MOV      A,t_ge
  1822.     MOVC     A,@A+DPTR
  1823.     MOV      R7,A
  1824.     LCALL    _senddata
  1825. ; senddata(table1[t_xiao1]);
  1826.             ; SOURCE LINE # 400
  1827.     MOV      A,t_xiao1
  1828.     MOVC     A,@A+DPTR
  1829.     MOV      R7,A
  1830.     LCALL    _senddata
  1831. ;                      
  1832. ;            
  1833. ;                    
  1834. ;                         senddata(0x0d);
  1835.             ; SOURCE LINE # 404
  1836.     MOV      R7,#0DH
  1837.     LCALL    _senddata
  1838. ;                         senddata(0x0a);
  1839.             ; SOURCE LINE # 405
  1840.     MOV      R7,#0AH
  1841.     LCALL    _senddata
  1842. ;                         com_flag=0;  //******置1后,按键无法控制  联机状态按键失效,ad指令后恢复按键控制
  1843.             ; SOURCE LINE # 406
  1844.     CLR      com_flag
  1845. ;          }
  1846.             ; SOURCE LINE # 407
  1847. ?C0049:
  1848. ;              
  1849. ;                 if(table[5]=='v'&&table[6]=='_'&&table[7]=='c'&&table[8]=='d')
  1850.             ; SOURCE LINE # 409
  1851.     MOV      A,table+05H
  1852.     CJNE     A,#076H,?C0050
  1853.     MOV      A,table+06H
  1854.     CJNE     A,#05FH,?C0050
  1855.     MOV      A,table+07H
  1856.     CJNE     A,#063H,?C0050
  1857.     MOV      A,table+08H
  1858.     CJNE     A,#064H,?C0050
  1859. ;                 {
  1860.             ; SOURCE LINE # 410
  1861. ;                            key_flag=2;
  1862.             ; SOURCE LINE # 411
  1863.     MOV      key_flag,#02H
  1864. ;                             // v_cd=0;
  1865. ;                             //v_fd=1;
  1866. ;                                               com_flag=1; //******置1后,按键无法控制  第2处 发送ad指令后可恢复按键控制
  1867.             ; SOURCE LINE # 414
  1868.     SETB     com_flag
  1869. ;                 }
  1870.             ; SOURCE LINE # 415
  1871. ?C0050:
  1872. ;                 if(table[5]=='v'&&table[6]=='_'&&table[7]=='f'&&table[8]=='d')
  1873.             ; SOURCE LINE # 416
  1874.     MOV      A,table+05H
  1875.     CJNE     A,#076H,?C0051
  1876.     MOV      A,table+06H
  1877.     CJNE     A,#05FH,?C0051
  1878.     MOV      A,table+07H
  1879.     CJNE     A,#066H,?C0051
  1880.     MOV      A,table+08H
  1881.     CJNE     A,#064H,?C0051
  1882. ;                 {
  1883.             ; SOURCE LINE # 417
  1884. ;                            key_flag=3;
  1885.             ; SOURCE LINE # 418
  1886.     MOV      key_flag,#03H
  1887. ;                             // v_cd=1;
  1888. ;                             //v_fd=0;
  1889. ;                                               com_flag=1;   //******置1后,按键无法控制  第3处 发送ad指令后可恢复按键控制
  1890.             ; SOURCE LINE # 421
  1891.     SETB     com_flag
  1892. ;                 }
  1893.             ; SOURCE LINE # 422
  1894. ?C0051:
  1895. ;                  if(table[5]=='v'&&table[6]=='o'&&table[7]=='f'&&table[8]=='f')
  1896.             ; SOURCE LINE # 423
  1897.     MOV      A,table+05H
  1898.     CJNE     A,#076H,?C0052
  1899.     MOV      A,table+06H
  1900.     CJNE     A,#06FH,?C0052
  1901.     MOV      A,table+07H
  1902.     CJNE     A,#066H,?C0052
  1903.     MOV      A,table+08H
  1904.     CJNE     A,#066H,?C0052
  1905. ;                {
  1906.             ; SOURCE LINE # 424
  1907. ;                             key_flag=1;
  1908.             ; SOURCE LINE # 425
  1909.     MOV      key_flag,#01H
  1910. ;                             //v_cd=1;
  1911. ;                             //v_fd=1;
  1912. ;                             com_flag=1;   //******置1后,按键无法控制  第4处 发送ad指令后可恢复按键控制
  1913.             ; SOURCE LINE # 428
  1914.     SETB     com_flag
  1915. ;                }
  1916.             ; SOURCE LINE # 429
  1917. ?C0052:
  1918. ;                            i=0;    
  1919.             ; SOURCE LINE # 430
  1920.     MOV      i,#00H
  1921.     MOV      i+01H,#00H
  1922. ;                 }        
  1923.             ; SOURCE LINE # 431
  1924. ;   }
  1925.             ; SOURCE LINE # 432
  1926. ?C0053:
  1927.     POP      AR7
  1928.     POP      AR0
  1929.     POP      PSW
  1930.     POP      DPL
  1931.     POP      DPH
  1932.     POP      ACC
  1933.     RETI    
  1934. ; END OF interrupt_uart
  1935. CSEG    AT    0000BH
  1936.     LJMP    T0_time
  1937. ;
  1938. ; void T0_time() interrupt 1
  1939.     RSEG  ?PR?T0_time?1602
  1940.     USING    0
  1941. T0_time:
  1942.     PUSH     ACC
  1943.     PUSH     B
  1944.     PUSH     PSW
  1945.     MOV      PSW,#00H
  1946.     PUSH     AR0
  1947.     PUSH     AR4
  1948.     PUSH     AR5
  1949.     PUSH     AR6
  1950.     PUSH     AR7
  1951.     USING    0
  1952.             ; SOURCE LINE # 434
  1953. ; {
  1954. ;         TH0=(65536-45872)/256;
  1955.             ; SOURCE LINE # 436
  1956.     MOV      TH0,#04CH
  1957. ;         TL0=(65536-45872)%256;
  1958.             ; SOURCE LINE # 437
  1959.     MOV      TL0,#0D0H
  1960. ;         num2++;
  1961.             ; SOURCE LINE # 438
  1962.     INC      num2+01H
  1963.     MOV      A,num2+01H
  1964.     JNZ      ?C0064
  1965.     INC      num2
  1966. ?C0064:
  1967. ;         if(num2==10)//原为20个循环1秒时基,屏幕刷新频率
  1968.             ; SOURCE LINE # 439
  1969.     XRL      A,#0AH
  1970.     ORL      A,num2
  1971.     JNZ      ?C0054
  1972. ;             {
  1973.             ; SOURCE LINE # 440
  1974. ;                     num2=0;
  1975.             ; SOURCE LINE # 441
  1976.     MOV      num2,A
  1977.     MOV      num2+01H,A
  1978. ;                     shan_flag=~shan_flag;
  1979.             ; SOURCE LINE # 442
  1980.     CPL      shan_flag
  1981. ;                     lcd_flag=1;
  1982.             ; SOURCE LINE # 443
  1983.     SETB     lcd_flag
  1984. ;             }
  1985.             ; SOURCE LINE # 444
  1986. ?C0054:
  1987. ;                        
  1988. ;          if(time_flag==1)
  1989.             ; SOURCE LINE # 446
  1990.     JNB      time_flag,?C0058
  1991. ;         {
  1992.             ; SOURCE LINE # 447
  1993. ;                 num1++;
  1994.             ; SOURCE LINE # 448
  1995.     INC      num1+01H
  1996.     MOV      A,num1+01H
  1997.     JNZ      ?C0065
  1998.     INC      num1
  1999. ?C0065:
  2000. ;                 if(num1==1200)//50ms*1200个循环为1分钟
  2001.             ; SOURCE LINE # 449
  2002.     CJNE     A,#0B0H,?C0058
  2003.     MOV      A,num1
  2004.     CJNE     A,#04H,?C0058
  2005. ;                 {
  2006.             ; SOURCE LINE # 450
  2007. ;                         num1=0;
  2008.             ; SOURCE LINE # 451
  2009.     MOV      num1,#00H
  2010.     MOV      num1+01H,#00H
  2011. ;                         time++;
  2012.             ; SOURCE LINE # 452
  2013.     INC      time+01H
  2014.     MOV      A,time+01H
  2015.     JNZ      ?C0067
  2016.     INC      time
  2017. ?C0067:
  2018. ;                         if(time==1000)
  2019.             ; SOURCE LINE # 453
  2020.     CJNE     A,#0E8H,?C0057
  2021.     MOV      A,time
  2022.     CJNE     A,#03H,?C0057
  2023. ;                             time=0;
  2024.             ; SOURCE LINE # 454
  2025.     MOV      time,#00H
  2026.     MOV      time+01H,#00H
  2027. ?C0057:
  2028. ;                         mah=aolt_z/60*time;
  2029.             ; SOURCE LINE # 455
  2030.     MOV      R6,aolt_z
  2031.     MOV      R7,aolt_z+01H
  2032.     MOV      R4,#00H
  2033.     MOV      R5,#03CH
  2034.     LCALL    ?C?SIDIV
  2035.     MOV      R4,time
  2036.     MOV      R5,time+01H
  2037.     LCALL    ?C?IMUL
  2038.     MOV      mah,R6
  2039.     MOV      mah+01H,R7
  2040. ;                 }
  2041.             ; SOURCE LINE # 456
  2042. ;         }
  2043.             ; SOURCE LINE # 457
  2044. ; }            ; SOURCE LINE # 458
  2045. ?C0058:
  2046.     POP      AR7
  2047.     POP      AR6
  2048.     POP      AR5
  2049.     POP      AR4
  2050.     POP      AR0
  2051.     POP      PSW
  2052.     POP      B
  2053.     POP      ACC
  2054.     RETI    
  2055. ; END OF T0_time
  2056.     END





本文内容包含图片或附件,获取更多资讯,请 登录 后查看;或者 注册 成为会员获得更多权限
快速回复
限80 字节
如果您提交过一次失败了,可以用”恢复数据”来恢复帖子内容
 
上一个 下一个