This is a sample that drives a speaker with PWM.

Dependencies:   EasyPlayback

Fork of GR-PEACH_Audio_WAV by Renesas

This is a sample that drives a speaker with PWM. This sample will play a ".wav" file of the microSD or USB memory root folder. If the USER_BUTTON0 is pressed, the next song is played.

/media/uploads/dkato/pwm_speaker_img.png

FormatWav file (RIFF format) ".wav"
Channel1ch and 2ch
Frequencies32kHz, 44.1kHz and 48kHz
Quantization bit rate8bits and 16bits


You can adjust the volume by changing the following.

main.cpp

AudioPlayer.outputVolume(0.5);  // Volume control (min:0.0 max:1.0)


The default setting of serial communication (baud rate etc.) in mbed is shown the following link.
Please refer to the link and change the settings of your PC terminal software.
The default value of baud rate in mbed is 9600, and this application uses baud rate 9600.
https://developer.mbed.org/teams/Renesas/wiki/GR-PEACH-Getting-Started#install-the-usb-serial-communication

Files at this revision

API Documentation at this revision

Comitter:
dkato
Date:
Mon Apr 18 09:17:50 2016 +0000
Parent:
7:4b6799c255ea
Child:
9:c7c0a97fdb7f
Commit message:
Supports IAR.

Changed in this revision

R_BSP.lib Show annotated file Show diff for this revision Revisions of this file
TLV320_RBSP.lib Show annotated file Show diff for this revision Revisions of this file
USBHost.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/R_BSP.lib	Tue Aug 18 04:19:19 2015 +0000
+++ b/R_BSP.lib	Mon Apr 18 09:17:50 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Renesas/code/R_BSP/#1390bfcb667c
+http://developer.mbed.org/teams/Renesas/code/R_BSP/#c5c630882b90
--- a/TLV320_RBSP.lib	Tue Aug 18 04:19:19 2015 +0000
+++ b/TLV320_RBSP.lib	Mon Apr 18 09:17:50 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Renesas/code/TLV320_RBSP/#b1fab4a2b59d
+http://developer.mbed.org/teams/Renesas/code/TLV320_RBSP/#15487e571d9f
--- a/USBHost.lib	Tue Aug 18 04:19:19 2015 +0000
+++ b/USBHost.lib	Mon Apr 18 09:17:50 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/USBHost/#220cd93c9a5f
+http://mbed.org/users/mbed_official/code/USBHost/#028508fd50fa
--- a/main.cpp	Tue Aug 18 04:19:19 2015 +0000
+++ b/main.cpp	Mon Apr 18 09:17:50 2016 +0000
@@ -21,8 +21,13 @@
 #define FLD_PATH               "/usb/"
 
 //4 bytes aligned! No cache memory
+#if defined(__ICCARM__)
+#pragma data_alignment=4
+static uint8_t audio_write_buff[AUDIO_WRITE_BUFF_NUM][AUDIO_WRITE_BUFF_SIZE]@ ".mirrorram";
+#else
 static uint8_t audio_write_buff[AUDIO_WRITE_BUFF_NUM][AUDIO_WRITE_BUFF_SIZE]
                 __attribute((section("NC_BSS"),aligned(4)));
+#endif
 //Tag buffer
 static uint8_t title_buf[TEXT_SIZE];
 static uint8_t artist_buf[TEXT_SIZE];
--- a/mbed.bld	Tue Aug 18 04:19:19 2015 +0000
+++ b/mbed.bld	Mon Apr 18 09:17:50 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/b9ad9a133dc7
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/082adc85693f
\ No newline at end of file