|
|||||||||||
|
Technical Support On-Line Manuals µVision User's Guide |
µVision User's Guidelegacy Signal CombinationSignal Functions or signal inputs can be easily combined. The following Signal Function shows how to invoke several signals so that they are processed in order.
//
// 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 ();
}
The Signal Function above setting generates the following output.
It is even possible to mix two sine wave signals as shown with the Signal Function below.
/*
* Generate a Sine Wave Input
*/
signal void mix_sine (float freq1, float freq2) {
float sig1;
float sig2;
int z;
z = 0;
while (z < 10000) { // generate 100 mSec sine wave pulse
/* Generate 1. Sine Wave input signal*/
sig1 = __sin (((states * freq1) / CLOCK) * 3.1415926 * 2);
/* Generate 2. Sine Wave input signal */
sig2 = __sin (((states * freq2) / CLOCK) * 3.1415926 * 2);
/* Input: 1. Sine Wave with 0.5V, 2. Sine Wave with 0.2V, offset 2.5V */
AN0 = (sig1 * 0.5) + (sig2 * 0.2) + 2.5;
swatch (0.00001); // wait 10 uSec
z++;
}
}
This Signal Function may be directly invoked from the command line to generate two frequencies. For example the invocation: mix_sine (300, 2000) generates an input signal with 300Hz and 0.5V amplitude and 2000Hz and 0.2V amplitude and an offset of 2.5V. The Logic Analyzer window below shows this signal.
| ||||||||||
|
|||||||||||