Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 5 months ago.
TLV320 WAV Player - does it still work?
I have imported the program from this page into my compiler: https://os.mbed.com/cookbook/TLV320-WAV-Player
When I compile the program, a .bin file is created but I get the error messages shown in the screenshot below. Presumably this code worked in 2012 when the program was published. What might have happened in the interim and how can I fix the errors please?
My hardware platform is LPC1768
When I run the program, the serial terminal returns the following message
Setting up pins.... Hmm....0
Edit #1 Ok, I forgot to use the pull up resistors on the I2C pins of the TLV320. Now that I have corrected that, the printf output is
Setting up pins.... Hmm....0 In Host_Init Initializing Host Stack Host Initialized Connect a Mass Storage device Mass Storage device connected Successfully initialized mass storage interface; 30892031 blocks of size 512 Inquiry reply: Peripheral device type: 00h .- Direct access (floppy) Removable Media Bit: 1 ANSI Version: 02h .- warning! must be 0 ECMA Version: 00h ISO Version: 00h Response Data Format: 02h .- warning! should be 1 Additional length: 43h .- warning! should be 1Fh Vendor Information: 'SanDisk' Product Identification: 'Cruzer Fit' Product Revision: '1.00'
There is now an audio output from the TLV320 ! ( The USB drive has test.wav on it, downloaded from https://mbed.org/media/uploads/p07gbar/test.wav)
Would still appreciate some reassurance on the warning messages output by the mbed compiler and the program itself. I don't know how important they are or how to fix them.
1 Answer
6 years, 4 months ago.
Hello there,
I'm glad that you were able to fix the issue! As for the compiler, the warnings that appear should be harmless to the program. However, if you would like to fix them, they should be relatively simple fixes:
The first warning “Transfer of control bypasses…” is because the switch statement is treated as a goto statement. As a goto, C++ language does not allow you to bypass declarations with initializations. To fix the warning, you should add curly braces around all the cases in order to contain them within a local scope:
TLV320.cpp
case line_in_vol_left: { temp = int(li_vol_left * 32) - 1; mute = li_mute_left; if(temp < 0) { temp = 0; mute = true; } cmd = temp & 0x1F; cmd |= mute << 7; break; }
The next two warnings follow the rule that data members should be initialized in the order they were declared in the class definition. To fix the warnings, you should go into WavPlayer.h and change the order of flag_play, i2s, and codec to match the order of their initializer list:
WavPlayer.cpp
WavPlayer::WavPlayer() : flag_play(true), i2s(I2S_TRANSMIT, p5, p6, p7), codec(p9, p10)//, ext_flag(p22), //run_flag(p23) {
WavPlayer.h
bool flag_play; I2S i2s; TLV320 codec;
The final warnings for “variable <blank> was declared…” appear because the program never uses those variables after they are initially declared. Hope this helps!
-Karen, team Mbed
If this solved your question, please make sure to click the "Thanks" link below!