16bit resolution PWM wave player with SD card, super lite version.
Dependencies: mbed DirectSPI FastPWM
Supported boards (confirmed):
Nucleo-F030R8
Nucleo-L152RE
Nucleo-F401RE
Nucleo-F411RE
Only compilation is OK (unchecked, but may work):
Nucleo-L073RZ
Nucleo-F334R8
Nucleo-F303RE
Nucleo-F429ZI
Nucleo-F446RE
Nucleo-F446ZE
Nucleo-L476RG
Supported SD card:
SDSC/SDHC card,
FAT16 and FAT32.
(1) At first, format SD card using SD Card Formatter
https://www.sdcard.org/downloads/formatter_4/index.html
(2) Copy PCM wav files to the SD card.
Supported file:
PCM wave file that have file extension ".wav" on root directory.
16bit/8bit, fs(sampling rate)=32kHz,44.1kHz,48kHz.
Stereo/Mono.
Hardware setting:
Refer to the file port_setting.txt
PWM output port:
Left upper(Hi) PWM 8bit out: PB_5 (TM3_CH2)
Right upper(Hi) PWM 8bit out: PB4 (TM3_CH1)
Left lower(Low) PWM 8bit out: PC_9 (TM3_CH4)
Right lower(Low) PWM 8bit out: PC_8 (TM3_CH3)
USER_BUTTON: PC_13(default button)
Next song: One click in Play mode.
Pause : Push long time .
Play : One click from Pause.
Diff: wave_player_main.cpp
- Revision:
- 20:c7066a530b1f
- Parent:
- 19:54aed6200a35
- Child:
- 21:dc161a192ba7
diff -r 54aed6200a35 -r c7066a530b1f wave_player_main.cpp --- a/wave_player_main.cpp Wed Sep 16 20:36:42 2020 +0900 +++ b/wave_player_main.cpp Fri Oct 09 07:38:47 2020 +0900 @@ -73,18 +73,18 @@ } #endif //# Gain up - dword wL = (((word)bL_hi)<<8) + bL_low; - dword wR = (((word)bR_hi)<<8) + bR_low; - wL <<= bGainNormalizeFactor; - wR <<= bGainNormalizeFactor; + dword dwL = (((word)bL_hi)<<8) + bL_low; + dword dwR = (((word)bR_hi)<<8) + bR_low; + dwL <<= bGainNormalizeFactor; + dwR <<= bGainNormalizeFactor; //# change pwm duties - pwm_dutyL_hi( wL >> 8); - pwm_dutyL_low( wL & 0xff); - pwm_dutyR_hi( wR >> 8); - pwm_dutyR_low( wR & 0xff); + pwm_dutyL_hi( dwL >> 8); + pwm_dutyL_low( dwL & 0xff); + pwm_dutyR_hi( dwR >> 8); + pwm_dutyR_low( dwR & 0xff); #else // not PWM16BIT - word wL =0,wR = 0; + word wL,wR; if( lbSample_bits == 16 ) { wL = wR = ((word)(send_ff() + (send_ff()<<8) + 0x8000))>>gPcmShifNum; lwReadCount -= 2;