📄 dac842.lst
字号:
C51 COMPILER V5.50, DAC842 20/10/03 09:03:14 PAGE 1
DOS C51 COMPILER V5.50, COMPILATION OF MODULE DAC842
OBJECT MODULE PLACED IN DAC842.OBJ
COMPILER INVOKED BY: C:\ADUC\BIN\C51.EXE DAC842.C DB
stmt level source
1 //dac842.c
2 /*
3 Author: Eckart Hartmann Date:17/10/2003
4 Description of Software:
5 This program demonstrates the DAC functions
6 <A HREF="/mcc/softw/842/dac/Dac842Cfg.html">DacCfg()</A>,<A HREF="/mcc/softw/842/dac/Dac842Out.html">DacO
-ut()</A>,
7 See PrintHelp() for details.
8 This code assumes a 32kHz crystal and 9600 baudrate.
9 Development progress: <A HREF="/mcc/softw/842/dac/Dac842Df.html">Dac842.df</A>
10 */
11 #include"..\kei842.h" //;<A HREF="/mcc/softw/842/Kei842Sfr.html">SFR definition file</A>.
12 #include"..\lib842.h" //;<A HREF="/mcc/softw/842/Lib842H.html">Function and variable declaration file</A>.
13 #include<stdio.h> //"stdio.h"
14 #include<ctype.h> //"ctype.h"
15 #include<stdlib.h> //"stdlib.h"
16
17 void PrintHelp(void);
18
19 void main(void)
20 {
21 1 char c1; //Temporary variable.
22 1 char cXRef; //External ref flag ('R' pressed).
23 1 char cChan; //Selected channel.
24 1 int iVal;
25 1 int i1;
26 1
27 1 UrtCfg(0x33,0x832d); //<A HREF="/mcc/softw/842/urt/Urt842Cfg.html">UrtCfg</A> configures UART.
28 1 PrintHelp();
29 1 DacCfg(0x1f);
30 1 while(1)
31 1 {
32 2 if(UrtBsy()&1) //If key pressed.
33 2 { // Act on command.
34 3 while((c1 = _getkey())=='w'); //Wait if 'w'.
35 3 if(c1=='r' || c1=='R')
36 3 { //Ramp.
37 4 putchar(c1);
38 4 if(c1=='r') cChan = 0;
39 4 else cChan = 1;
40 4 for(i1=0; i1<0x1000; i1++)
41 4 DacOut(cChan,i1);
42 4 }
43 3 else if(c1=='f' || c1=='F')
44 3 { //Full scale.
45 4 putchar(c1);
46 4 if(c1=='f') cXRef = 0;
47 4 else cXRef = 1;
48 4 DacCfg(0x1f+0x60*cXRef);
49 4 }
50 3 else if(c1=='h') PrintHelp();
51 3 else if(c1=='0' || c1=='1')
52 3 {
53 4 putchar(c1);
54 4 putchar(':');
55 4 cChan = c1-'0';
56 4 iVal = (getchar()-'0')*1000;
57 4 iVal += (getchar()-'0')*100;
58 4 iVal += (getchar()-'0')*10;
C51 COMPILER V5.50, DAC842 20/10/03 09:03:14 PAGE 2
59 4 iVal += (getchar()-'0');
60 4 DacOut(cChan,iVal);
61 4 } }
62 2 }
63 1 }
64 void PrintHelp(void)
65 {
66 1 printf("To change settings during conversions press one of:\n");
67 1 printf("\t f for Vref full scale.\n");
68 1 printf("\t F for AVdd full scale.\n");
69 1 printf("\t r to ramp DAC0 full scale.\n");
70 1 printf("\t R to ramp DAC1 full scale.\n");
71 1 printf("\t 0 plus 4 digits for that output on DAC0.\n");
72 1 printf("\t 1 plus 4 digits for that output on DAC1.\n");
73 1 printf("\t h for this help screen.\n");
74 1 printf("\t w to wait.\n");
75 1 printf("Press a key to end help.\n\n");
76 1 _getkey();
77 1 }
78
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 407 ----
CONSTANT SIZE = 321 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 2 7
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -