?? dmeasure.ini
字號:
Load measure.dmo
g, main
/*-------------------------------------------*/
/* Function MyRegs() shows Registers R0...R3 */
/*-------------------------------------------*/
FUNC void MyRegs (void) {
printf ("---------- MyRegs() ----------\n");
printf (" R0 R1 R2 R3\n");
printf (" %02X %02X %02X %02X\n");
printf ("------------------------------\n");
}
//
// Generate Saw Tooth Signal on A/D input AD01
//
signal void AD01_Saw (void) {
float volts; // peak-to-peak volatage
float frequency; // output frequency in Hz
float offset; // volatge offset
float duration; // duration in Seconds
float delay;
float val;
long i, end, steps;
volts = 2.0;
offset = 0.2;
frequency = 140;
duration = 8.0;
printf ("Saw Tooth Signal on A/D input AD01\n");
steps = 100;
delay = (0.01/frequency);
printf ("Saw Steps = %d\n", steps);
end = (duration * 10000);
for (i = 0 ; i < end; i++) {
val = (i % steps) / ((float) steps);
AD01 = (val * volts) + offset;
swatch (delay);
}
}
//
// Generate Sine Wave Signal on A/D input AD02
//
signal void AD02_Sine (void) {
float volts; // peak-to-peak volatage
float frequency; // output frequency in Hz
float offset; // volatge offset
float duration; // duration in Seconds
float val;
long i, end;
volts = 1.4;
offset = 1.6;
frequency = 180;
duration = 5.0;
printf ("Sine Wave Signal on A/D input AD02\n");
end = (duration * 10000);
for (i = 0 ; i < end; i++) {
val = __sin (frequency * (((float) STATES) / CLOCK) * 2 * 3.1415926);
AD02 = (val * volts) + offset;
swatch (0.0001); // in 100 uSec steps
}
}
//
// Generate Noise Signal on A/D input AD03
//
signal void AD03_Noise (void) {
float volts; // peak-to-peak volatage
float frequency; // output frequency in Hz
float offset; // volatge offset
float duration; // duration in Seconds
float val;
long i, end;
volts = 1.4;
offset = 1.6;
duration = 0.5;
printf ("Noise Signal on A/D input AD03\n");
end = (duration * 100000);
for (i = 0 ; i < end; i++) {
val = ((float) rand (0)) / 32767.0;
AD03 = (val * volts) + offset;
swatch (0.00001); // in 10 uSec steps
}
}
//
// Run Signal Functions at Startup
//
signal void Startup (void) {
swatch (1.0); // wait 1.0 seconds
AD01_Saw ();
swatch (0.3); // wait 0.3 seconds
AD02_Sine ();
swatch (0.6); // wait 0.6 seconds
AD03_Noise ();
}
Startup (); // Start the Signals
define button "AD01 Saw Tooth", "AD01_Saw ()"
define button "AD02 Sine Wave", "AD02_Sine ()"
define button "AD03 Noise Signal", "AD03_Noise ()"
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -