cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f4 discovery USB and MP3 on the verge to make it work but..

Electronic1
Associate II
Posted on January 12, 2017 at 13:28

Hello to everyone,

I've been searching in the web to find and example of this typicall aplication of reporducing MP· files from a USB stick, with the stm32f4 discovery board.

At first I found the code (

http://vedder.se/2012/12/stm32f4-discovery-usb-host-and-mp3-player/

 ) but I work with keil and I didn't succes to make it work with Keil.

Looking harder I've found and example with keil.

http://shuji009.blog.eonet.jp/default/2012/03/stm32f4mp32-30df.html

 

The explanations are in japanese so I had to translate them with google. And even I followed the instructions of the programmer:(

which are: comment  AUDIO_MAL_MODE_NORMAL and uncomment AUDIO_MAL_MODE_CIRCULAR in  stm32f4_discovery_audio_codec.h file

and also: uncomment AUDIO_MAL_DMA_IT_HT_EN in the same file )

I can't make it works.

The japanese code breaks(HardFault_Handler) in the mp3.dec file, in the function 'HMP3Decoder MP3InitDecoder(void)' after executing the AllocateBuffers

Anyone could help to make it work?

Thanks in advance

8 REPLIES 8
Electronic1
Associate II
Posted on January 13, 2017 at 08:33

I have found another code. This time in german

http://mikrocontroller.bplaced.net/wordpress/?page_id=2272

  but I still haven't get to port it to keil

:(

Electronic1
Associate II
Posted on January 13, 2017 at 09:08

Looking inside the ST documentation it seems that they have already done an specific library code for MP3, but it's not populated. How you can get this library?

http://www.st.com/en/embedded-software/stm32-mp3nl-cod.html

 
AvaTar
Lead
Posted on January 13, 2017 at 09:09

If an imported (and supposedly working) project fails, the problem is most probably outside the source code.

A too small stack is a good candidate for hardfaults.  I would check what the 'AllocateBuffers' function actually does. Or, the author has changed the linker script/file and adapted the stack/heap sizes to make it work. You will need to port those changes to your environment, then.

Changing compiler optimization settings (upwards) is also known to 'break' certain code ...

Electronic1
Associate II
Posted on January 13, 2017 at 13:34

Got it!

The following changes are needed to make it work.

in stm32f4_discovery_audio_codec.h  file:

Enable # define AUDIO_MAL_MODE_CIRCULAR

Also enable #define AUDIO_MAL_DMA_IT_HT_EN.

#define AUDIO_MAL_MODE_NORMAL needs to be commented out.

 IN

stm32f4_discovery_audio_codec.c

EVAL_AUDIO_TransferComplete_CallBack((uint32_t)pAddr, Size);

Now it still sounds as double speed but I solve it.

Posted on January 13, 2017 at 13:07

Many thanks AvaTar!, you were right I have changed the stack size in the startup_stm32f4xx.s

Stack_Size      EQU     0x00001000 

And now it works without crashing.

But it still doesn't produce any noise. I will continue testing.

Posted on January 16, 2017 at 09:35

Hello Mr Feixas,

which project did You make work?

1. Benjamin's robotics STM32F4 Discovery USB host and MP3 player

OR

2. Japanese blog

Daily work (memo)

STM32F4 Migrating MP3 (2) ~ For the time being

I tried both to some extent, but I could not make them work.

Actually I'm lost since first part of the application, that is USB host MSD and then FAT32 File System.

Thank You,

Giacomo

Posted on January 16, 2017 at 09:50

Hello Mr.Zaffini.

The japanese blog project is the one which worked for me.

You have just to download it and add the project folder inside the 'Project' library of the st given library for the discovery board ->  STM32F4-Discovery_FW_V1.1.0\Project

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32-standard-peripheral-libraries-expansions/stsw-stm32068.html

 

And then apply all the changes I explained before.

Posted on January 18, 2017 at 15:23

Thanks Mr. Feixas.

I'll try harder with stm32f4-discovery board next weekend following Your advices.

Since You accomplished building a mp3 player, i wonder if a bigger project is of Your interest,

I saw on YT this one which took my attention, it has added resources and a custom shield

https://youtu.be/0ETyFmAMFjY

linking to this site page

http://motionplayer.wiki.fc2.com/

which has source code link and other resources.

Thank You again,

Giacomo