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.
main.cpp
- Committer:
- mimi3
- Date:
- 2019-01-15
- Revision:
- 0:9a5c2fb0d96f
- Child:
- 10:1108261dabe8
File content as of revision 0:9a5c2fb0d96f:
#include "sys.h" #include "sd_card.h" #include "fat_lib.h" #include "pwm_lib.h" #include "wave_player_main.h" /* SD card pin Pin side --------------\ 9 = \ DAT2/NC 1 ===| CS/DAT3 [CS] 2 ===| CMD/DI [DI] 3 ===| VSS1 Bottom 4 ===| VDD View 5 ===| CLK [CLK] 6 ===| VSS2 7 ===| DO/DAT0 [DO] 8 =| DAT1/IRQ ----------------- Arduino NUCLEO-F411 NUCLEO-F030R8 Logo side ----------------- 8 =| DAT1/IRQ 7 ===| DO/DAT0 [DO] D12 D12/PA_6 D12/PA_6 6 ===| VSS2 Top 5 ===| CLK [CLK] D13 D13/PA_5 D13/PA_5 View 4 ===| VDD 3 ===| VSS1 2 ===| CMD/DI [DI] D11 D11/PA_7 D11/PA_7 1 ===| CS/DAT3 [CS] D8 D10/PB_6 D10/PB_6 9 = / DAT2/NC --------------/ */ #if UART_INFO Serial pc(USBTX,USBRX); #endif int main() { #if UART_INFO setbuf(stdout,0); pc.baud(115200); #endif wait_us(100*1000); /* wait 100msec */ pwm_init(); sd_init(); FAT_init(); wave_player_main(); }