?? startup_sim.ini
字號(hào):
//
// Generate Saw Tooth Signal on AD Channel 0
//
signal void ADC0_Saw (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, steps;
volts = 2.0;
offset = 0.2;
frequency = 1400;
duration = 0.2;
printf ("Saw Tooth Signal on AD Channel 0.\n");
steps = (100000 * (1/frequency));
end = (duration * 100000);
for (i = 0 ; i < end; i++) {
val = (i % steps) / ((float) steps);
ADC0 = (val * volts) + offset;
swatch (0.00001); // in 10 uSec increments
}
}
//
// Generate Sine Wave Signal on AD Channel 0
//
signal void ADC0_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 = 1800;
duration = 0.1;
printf ("Sine Wave Signal on AD Channel 0.\n");
end = (duration * 100000);
for (i = 0 ; i < end; i++) {
val = __sin (frequency * (((float) STATES) / CLOCK) * 2 * 3.1415926);
ADC0 = (val * volts) + offset;
swatch (0.00001); // in 10 uSec steps
}
}
//
// Generates an Square Wave Signal on AD Channel 0
//
signal void ADC0_Square (void) {
float volts; // peak-to-peak volatage
float frequency; // output frequency in Hz
float offset; // volatge offset
float duration; // duration in Seconds
volts = 0.5;
offset = 1.6;
frequency = 2400;
duration = 0.5;
printf ("Square Wave Signal on AD Channel 0.\n");
while (duration > 0.0) {
ADC0 = volts + offset;
swatch (0.5 / frequency);
ADC0 = offset;
swatch (0.5 / frequency);
duration -= 1.0 / frequency;
}
}
//
// Combine the Signals
//
signal void Startup (void) {
swatch (1.0); // wait 1.0 seconds
ADC0_Saw ();
swatch (0.3); // wait 0.3 seconds
ADC0_Square ();
swatch (0.6); // wait 0.6 seconds
ADC0_Sine ();
}
Startup (); // Start the Signals
define button "ADC0 Sine Wave", "ADC0_Sine ()"
define button "ADC0 Saw Tooth", "ADC0_Saw ()"
define button "ADC0 Square Wave", "ADC0_Square ()"
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -