MP3 Audio Decoder on STM32F4 Discovery (updated 30/10/2012) – ChibiOS 2.4.2

Posted by

I like the work that was done by Marco W. (watz) on that forum.

Using the same hardware (SD Card connected to PA5/6/7 and PC4), ChibiOS 2.4.x and LibMAD (instead of Helix),
I finally have managed to get some output…

Most of the code comes from Marco W. ‘s work, I only tried to replace the stm32 audio discovery code by
functions provided by chibiOS (for I2C / I2S via SPI code and DMA).

Here is the code (you need to have ChibiOS sources too).

Update 23/09/2012 : Thanks to a comment by Deanrock, I have repackaged the source code with the I2C
modification & I have tested recompilation using a current Sourcery Code Bench (gcc version 4.6.3 – Sourcery CodeBench Lite 2012.03-56) and Chibios 2.4.2 (this version does not require any patching, just deflate fatfs from the ‘ext’ folder).

Here is the New code

Update 30/10/2012 : with my first tests, I had to enable the chibiOS debugs to get a stable behaviour. It looks like it is running just fine without, provided that -O2 is used (instead of -Os) and that CORTEX_USE_FPU is set to FALSE.

User button is used to skip to the next file.
This one was only tested with Chibios 2.4.2.

Here is the New code

11 comments

  1. Which compiler did you use to compile your code?
    I have tried https://github.com/esden/summon-arm-toolchain/ and CodeSourcery, but in both cases my board stops working (orange and green LEDs are on and nothing else executes) after calling i2cStart(&I2CD1, &i2cfg) which is called with EVAL_AUDIO_Init(0,70,44100).

    If I flash it with your .bin file, everything works fine.

    1. Nevermind, I changed I2C speed from 120000 to 400000 and now it works.

      static I2CConfig i2cfg = {
      OPMODE_I2C,
      400000,
      FAST_DUTY_CYCLE_2
      //STD_DUTY_CYCLE
      };

      1. Thanks for your comment – I have not noticed the same behaviour on my board, but maybe your fix can help others.

  2. Hi there, just wanted to say thanks a lot. I was able to to compile your project and transfer it. It plays well, but:

    “All chibios debugs are enabled (there were problems in the audio
    ouput (chirps) when they weren’t, so I kept them on…)”

    Have you found out what causes the chirps? I experience the same problems as well.

    Thanks beforehand for any reply!

    1. Thanks for your comment.

      I had no free time to continue the project, thus no idea about the cause of chirps without chibios debugs…
      Sorry.

      JJ

      1. I took some time to re-evaluate the problem : with compile flag -O2 and no FPU options, it looks ok even without Chibios debug options.
        Please try the 30/10/2012 sources with Chibios 2.4.2.

        JJ

    1. That was not related to performance (I have no idea which one performs the best), but only because libmad was light and simple to use. Cortex-M4 specific dsp instructions were not needed, but it looks simplier to use them in libmad than in helix code (IMHO).
      For example the output saturation code for libmad could be implemented by just an asm inline line in the mad.c file.

  3. I am using helix lib for stm32 decoding but I have trouble with assembly.h. Can U give me more detail about this project

Leave a Reply to admin Cancel reply

Your email address will not be published. Required fields are marked *