You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<aid="user-content-pcm-wave-player-super-lite-with-nim-language-on-stm32-mcus" class="anchor" href="#pcm-wave-player-super-lite-with-nim-language-on-stm32-mcus" aria-hidden="true"><spanaria-hidden="true" class="octicon octicon-link"></span></a>PCM Wave Player Super Lite with Nim language on STM32 MCUs</h3>
70
+
<p>16bit resolution PWM wave player with SD card, super lite version.</p>
<p>You can just copy the <strong>bin</strong> file to mbed drive,
226
+
or can flash the <strong>hex</strong> file with ST-Link utility.</p>
227
+
<p>If you don't like to compile from source code, you can immediately upload <ahref="https://github.com/dinau/stm32-wave-player-pwm-super-lite-nim/tree/main/doc/hex">doc/hex/*.hex or *.bin files</a> to flash.</p>
228
+
<h4>
229
+
<aid="user-content-output-music-filename--through-uart-port" class="anchor" href="#output-music-filename--through-uart-port" aria-hidden="true"><spanaria-hidden="true" class="octicon octicon-link"></span></a>Output music filename through UART port</h4>
230
+
<p>By default music filename is send through default UART(USB-CDC(Nucleo boards)) port.
231
+
Baudrate is <strong>115200bps</strong>.<br>
232
+
<p><imgsrc="http://mpu.up.seesaa.net/image/filename-to-uart-port.png"></p>If you don't need UART output feature, set <strong>UART_INFO* = false</strong> in <ahref="https://github.com/dinau/stm32-wave-player-pwm-super-lite-nim/blob/main/src/conf_sys.nim">src/conf_sys.nim</a> and<br>
233
+
recompile the project.</p>
234
+
<h4>
235
+
<aid="user-content-simple-less-bits-mode" class="anchor" href="#simple-less-bits-mode" aria-hidden="true"><spanaria-hidden="true" class="octicon octicon-link"></span></a>Simple less bits mode</h4>
236
+
<p>If set <strong>PWM16BIT* = false</strong> in src/conf_sys.nim and recompile the project, <strong>simple less bits mode</strong> is enabled.<br>
237
+
In spite of less parts, wirings and PCM bit length, it has fairly sound quality.
238
+
<p><imgsrc="http://mpu.up.seesaa.net/image/less-bits-wave-player-output-schema.png"></p><p><strong>Table 1.</strong> Sound resolution in <strong>simple less bits mode</strong></p>
239
+
<table>
240
+
<thead>
241
+
<tr>
242
+
<thalign="left">Board</th>
243
+
<thalign="right">Sound resolution</th>
244
+
<thalign="right">TIM_PWM_BASE_CLOCK</th>
245
+
</tr>
246
+
</thead>
247
+
<tbody>
248
+
<tr>
249
+
<tdalign="left">nulceo_f030r8</td>
250
+
<tdalign="right">10bit</td>
251
+
<tdalign="right">48MHz</td>
252
+
</tr>
253
+
<tr>
254
+
<tdalign="left">nucleo_l152re</td>
255
+
<tdalign="right">9bit</td>
256
+
<tdalign="right">32MHz</td>
257
+
</tr>
258
+
<tr>
259
+
<tdalign="left">nulceo_f401re</td>
260
+
<tdalign="right">10bit</td>
261
+
<tdalign="right">84MHz</td>
262
+
</tr>
263
+
<tr>
264
+
<tdalign="left">nulceo_f411re</td>
265
+
<tdalign="right"><strong>11bit</strong></td>
266
+
<tdalign="right">96MHz</td>
267
+
</tr>
268
+
<tr>
269
+
<tdalign="left">STM32F0Discovery</td>
270
+
<tdalign="right">10bit</td>
271
+
<tdalign="right">48MHz</td>
272
+
</tr>
273
+
<tr>
274
+
<tdalign="left">STM32F3Discovery</td>
275
+
<tdalign="right">10bit</td>
276
+
<tdalign="right">64MHz</td>
277
+
</tr>
278
+
<tr>
279
+
<tdalign="left">STM32F4Discovery</td>
280
+
<tdalign="right">10bit</td>
281
+
<tdalign="right">84MHz</td>
282
+
</tr>
283
+
</tbody>
284
+
</table>
285
+
<h4>
286
+
<aid="user-content-pursue-small-code-size" class="anchor" href="#pursue-small-code-size" aria-hidden="true"><spanaria-hidden="true" class="octicon octicon-link"></span></a>Pursue small code size</h4>
287
+
<p>In src/conf_sys.nim,by eliminating some functionalities, the code size can be further reduced.
288
+
For instance, set as follows:<br>
289
+
<strong>UART_INFO* = false</strong>
290
+
<strong>PWM16BIT* = false</strong> ( set simple less bits mode)<br>
291
+
<strong>DATA_8BIT_SUPPORT* = false</strong> ( only support PCM16bit format,neglect PCM8bit format)
292
+
<strong>HAVE_LED_IND_PWM* = false</strong> ( eliminate LED indicator function)<br>
293
+
<strong>FS_48KHZ_QUP* = false</strong> ( only supoort less than fs=48KHz)<br>
294
+
will result in about:</p>
295
+
<pre><code>text data bss dec hex filename
296
+
2964 0 104 3068 bfc BUILD/nucleo_l152re.elf
297
+
</code></pre>
298
+
<p>In src/config.nims, uncomment and enable below option,</p>
299
+
<pre><code>--passC:"-flto"
300
+
--passL:"-flto"
301
+
</code></pre>
302
+
<p>and recompile project,</p>
303
+
<pre><code>make clean
304
+
make
305
+
</code></pre>
306
+
<p>will result in about:</p>
307
+
<pre><code>text data bss dec hex filename
308
+
2916 0 136 3052 bec BUILD/nucleo_l152re.elf
309
+
</code></pre>
310
+
<p>Now it can do auto playback after power on,<br>
311
+
can operate play,pause and next song with push button,<br>
312
+
be able to play fairly quality sound according to Table 1,
313
+
can recognize PCM 16bit wav file(but output quality is reduced accoding to Table 1. and supports stereo/mono, fs=32KHz,44.1KHz.</p>
<ahref="https://github.com/dinau/arduino-wave-player-pwm-super-lite-nim">Arduino Wave Player PWM Super Lite Nim / Nim</a> Completed.</li>
323
+
</ul>
324
+
</li>
325
+
<li>Mbed2 C/C++ language
326
+
<ul>
327
+
<li>
328
+
<ahref="https://os.mbed.com/users/mimi3/code/wave_player_super_lite" rel="nofollow">Wave Player Super Lite / STM32(F0,L1,F4) / Mbed2 / C++</a> Completed.</li>
329
+
</ul>
330
+
</li>
331
+
<li>Jal language
332
+
<ul>
333
+
<li><ahref="https://github.com/dinau/16f-wave-player-pwm-super-lite-jalv2">Pwm Wave Player Jalv2 / PIC16F1xxx / Jal</a></li>
0 commit comments