Basic Micro Studio Syntax Manual
Basic Micro Studio Syntax Manual
Basic Micro Studio Syntax Manual
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
FREQOUT<br />
<strong>Syntax</strong><br />
freqout pin, duration, freq1{,freq2}<br />
Commands<br />
• Pin - is a variable, constant or expression that specifi es the I/O pin to be used. This pin will be set<br />
to output mode during tone generation and then left in that state after output is completed.<br />
• Duration - is a variable, constant or expression that specifi es the duration of the output tone in<br />
milliseconds.<br />
• Freq1 - is a variable, constant or expression that specifi es the frequency in Hz of the fi rst tone<br />
which can be between 0 – 32767Hz.<br />
• Freq2 - is an optional variable, constant or expression that specifi es the frequency in Hz of the<br />
second tone which can be between 0 – 32767Hz.<br />
Supported<br />
• BA - Supported<br />
• BAN - Supported<br />
• BAP - Supported<br />
• BAP40 - Supported<br />
Description<br />
This command generates one or two tones that are output on a single I/O pin. The signal generated is<br />
a pulse width modulated signal. This command can be used to create music, tones or general output<br />
signals. The maximum supported range is limited to what is practical. There aren’t many speakers or<br />
piezo devices on the market that will work well outside of 30Khz, which is why M<strong>Basic</strong> is limited to a<br />
maximum of 32Khz.<br />
Notes<br />
1. The tones are generated mathematically and output as a pulse width modulated (PWM) signal.<br />
The signal must be converted to a sine wave (or a pair of sine waves) by passing it through an<br />
integrator which is a low pass fi lter.<br />
Example<br />
The code snippet below will generate a 1000Hz tone for 5 seconds on P1.<br />
freqout p1, 5000, 1000<br />
The next code snippet will generate two tones 1000Hz and 2000Hz for 5 seconds on P1.<br />
freqout p1, 5000, 1000, 2000<br />
110