Skip to main content
sgardner661
Associate II
May 7, 2013
Question

Audio via USART (STM32F4 Discovery)

  • May 7, 2013
  • 7 replies
  • 2667 views
Posted on May 07, 2013 at 03:07

I'm trying to create a project where I send an audio file from a computer to my STM32F4-Discovery board via USART and play the file. I have successfully run a USART example where a character is sent to the F4 board and back to the computer. I have also run a program where a mp3 file stored in flash memory is played.

I was wondering how I could integrate the two programs. The mp3 used in the program is actually an mp3 file that was converted into a series of hex characters (c array). How would I send that c array to the F4 board?

Here's the mp3 program I used:

http://vedder.se/2012/07/play-mp3-on-the-stm32f4-discovery/

#usart #mp3 #stm32f4 #uart #xmodem #audio
This topic has been closed for replies.

7 replies

Tesla DeLorean
Guru
May 7, 2013
Posted on May 07, 2013 at 04:04

The mp3 used in the program is actually an mp3 file that was converted into a series of hex characters (c array). How would I send that c array to the F4 board?

Why wouldn't you just send the unconverted binary data as 8-bit data over the serial port? RealTerm - Send File?

Accumulate the bytes at the receiving end and send off to the MP3 player. Not sure you have the bandwidth.
Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
sgardner661
Associate II
May 7, 2013
Posted on May 07, 2013 at 07:25

I've never used Realterm before, so can I send an mp3 file as is over the serial port?

Andrew Neil
Super User
May 7, 2013
Posted on May 07, 2013 at 12:06

Probably best to use a protocol such as XMODEM.

Any decent terminal app (even Hyperterminal) and many comms toolkits can do XMODEM.

The ST In-Application Programming (IAP) App Note uses XMODEM - so you have a ready example there (not a very good implementation, but it does work).

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Tesla DeLorean
Guru
May 7, 2013
Posted on May 07, 2013 at 13:46

I've never used Realterm before, so can I send an mp3 file as is over the serial port?

What is an MP3 file composed of? A stream of bytes. The serial port can transmit said bytes.

XMODEM would add a protocol layer to ensure the data arrives correctly, by potentially retrying corrupt blocks.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
sgardner661
Associate II
May 7, 2013
Posted on May 07, 2013 at 20:28

Ok I'm going to start working on that. By the way how would I find out if I have the bandwidth capabilities to perform this task? Is that referring to a limitation of the F4 board?

Tesla DeLorean
Guru
May 7, 2013
Posted on May 07, 2013 at 21:56

By the way how would I find out if I have the bandwidth capabilities to perform this task? Is that referring to a limitation of the F4 board?

A 128 Kbps MP3 will not fit down a pipe at 115200 baud.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
sgardner661
Associate II
May 8, 2013
Posted on May 08, 2013 at 05:36

Ahh ok well thanks for the help