Author Topic: Need help choosing microcontroller, going crazy (two channels wav playback)  (Read 12957 times)

0 Members and 1 Guest are viewing this topic.

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
So, I've tried to use parametric search for the vendors I have [minimal] experience with (atmel, nxp, texas instruments, renesas, ST micro) but I can't seem to find anything I think is suitable.

I'm just done with my previous paid project and it got way out of hand in terms of specs as the client wanted something totally illogical (javascript interpreter for an "iot" temperature sensor). Anyways, I'm tired of working with hardware that is way over engineered.

My question should you choose to care:
Which part would you choose if you wanted to make a product that plays two stereo 24bit@44.1kHz .wav files that should be uploaded to the device through USB?

My current thinking is that I need two I2S peripherals, one USB Mass Storage Class compliant host peripheral, and a good way to store audio. SD Card with SDIO or SPI mode? Internal FLASH IC?

I'm going crazy and have a hard time figuring out what is a good way to go. Anyone with experience playing audio off of SD? Is it fast enough in SPI mode?

Any replies are happily received!
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16561
  • Country: 00
My question should you choose to care:
Which part would you choose if you wanted to make a product that plays two stereo 24bit@44.1kHz .wav files that should be uploaded to the device through USB?

http://www.ebay.com/itm/171764616814

Edit: I just noticed those things claim to have a 24 bit DAC so there you go.

But... 24bits? What for?


« Last Edit: January 17, 2017, 10:07:00 am by Fungus »
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Tanks for the reply  :)
On the phone so having a hard time trying to update the previous post. Here are some qualifiers:
I don't need a codec as I can parse the wav files to get the PCM.
I want to be in control of the DACs as I'm going for phase coherency on the two streams.
Need at least 4GB storage.
24bit to meet a spec and fit in a prosumer/audio market.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
stm32 and a good quality stereo DAC is where i would start.
You want to use the STM32 DMA controller to do the data transfer to the DAC.
Use the stm32 usb mass storage example code to read the usb file system.

the STM32F103 is probably all you need and is very common/cheap
But you could probably do it with the cheaper STM32F0x2 to keep costs as low as possible
« Last Edit: January 17, 2017, 10:57:12 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 
The following users thanked this post: alexanderbrevig

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
My current mcus in the lead are; STM32 as my last project used an F103 and the PSoC 5 because I love them.
I'd not go for the F1 though I think..

Edit: saw you mention the exact same part I've been using. Maybe I should make it easy for myself and just reuse my knowledge...
« Last Edit: January 17, 2017, 11:01:36 am by alexanderbrevig »
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
STM32F4x7 have got stupid amounts of power, if you think you may need it

But that's probably way overkill.

Just get a stm32 that has USB and two dma controllers, one for each stereo DAC IC

« Last Edit: January 17, 2017, 11:03:47 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 
The following users thanked this post: alexanderbrevig

Offline bktemp

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: de
If you really need to upload the files over USB using the microcontroller, get one having HS-USB. Using FS-USB it will take forever to transfer 4GB.
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Thanks for getting me down the STM path (I was a bit tired of them and wanted to learn something new, but it's better to bank on my experience I think for this...)!

After looking through my box of devkits I actually found one for STM32F4 and it has a Cirrus DAC close to the one I've been looking for (as far as control and interface goes):


Also this:


I think I will go for the STM32F429 series.
Huge bonus with all the example code, design resources and all the jazz TI does!

Between those I can test both I2S and running an LCD directly.
I guess this would kind of count as over engineering, but I like the fact it has support for everything I want. Even HS USB :)

What do you guys think?
Stop pondering and get dirty?
 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
Excellent choice, I'm using the same board (STM32F407) to play 24 bit 96K WAV / FLAC to I2s ES9018K2M DAC and onboard CODEC simultaneously from a USB stick and am loving how it sounds.
It will do 192K but only on external DAC as onboard CODEC can only do 96K.
Just be aware that you will need an external phy chip for USB HS, both boards can only do USB FS.
« Last Edit: January 17, 2017, 12:19:40 pm by bobaruni »
 

Offline FreddyVictor

  • Regular Contributor
  • *
  • Posts: 164
  • Country: gb
Excellent choice, I'm using the same board (STM32F407) ..
actually, he's not quite, he's got the very similar but cheaper STM32F401 version (should be fine tho')
Excellent choice, I'm using the same board (STM32F407) to play 24 bit 96K WAV / FLAC to I2s ES9018K2M DAC and onboard CODEC simultaneously from a USB stick and am loving how it sounds.
It will do 192K but only on external DAC as onboard CODEC can only do 96K.
Just be aware that you will need an external phy chip for USB HS, both boards can only do USB FS.
sounds interesting :)
 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
actually, he's not quite, he's got the very similar but cheaper STM32F401 version (should be fine tho')
Ahh, yes agreed should be fine but may or may not do 192K on WAV and may or may not do 96K on FLAC.
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Thanks for the input everyone! I realize I need a ULPI between the connector and the chip. Sounds about right?

Funny you should say that about the USB stick, as I've had a chat here and changed the spec. Audio will now be played off of a usb thumb drive :)

I think 44.1 is fine for the application. I might even do 16 bit over 24. The device will be used in a live audio/concert setting, so...

Currently planning on the F429 over the F401 because I cant seem to find any evidence 401 supports USB-HS (not in datasheet, and not in cubemx).
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
aaaand as I've never used USB Host for anything I'm suddenly unsure if it's at all possible to get access in a random access fashion so I can stream two files!?
Going to get my reading (writing) glasses on and have at it!
 

Offline bktemp

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: de
ST uses this FAT filesystem driver:
http://elm-chan.org/fsw/ff/00index_e.html
It supports unlimited number of files open at the same time (until you run out of memory for all the file objects).
Random access for reading shouldn't be a problem, because flash memory is fast. When reading, read the file in large blocks (4-32kBytes).
If you want to write at the same time while streaming audio, you need a large buffer because wear leveling during writing can take a couple of seconds for slow devices.
 
The following users thanked this post: alexanderbrevig

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
Yes, you can stream multiple files using Chan's FatFS when configured correctly but remember you are limited to USB FS and then there's the overhead of the file system....
I suggest you start with the STM32 Cube HAL (Projects\STM32F401-Discovery\Applications\Audio\Audio_playback_and_record)....it's limited to 16 bit files and the CODEC clock setting is way off due to a bug but it's a good starting point, otherwise you are in for quite some work without the example.
 
The following users thanked this post: alexanderbrevig

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Thanks for the FAT reference! Already playing with the record/play example. I've changed the PLLs to get a more satisfying and appropriate setup for me (I started from "scratch" with CubeMX and pasted in what I wanted from the example). Audio is playing! WOHO
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13695
  • Country: gb
    • Mike's Electric Stuff
PIC32MZ may be worth a look ( the more recent EF ones with the less ridiculous errrata list). One big advantage is thay have tons of RAM -up to 512K -  you may need a fair bit for buffering USB lumpiness

They have 4-6 SPI ports which have I2S support ( I think on all of them), as well as HS USB Host, and come in sensible QFP packages.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Online amyk

  • Super Contributor
  • ***
  • Posts: 8240
Funny you talk about overengineering and then look at many of the replies here... I'd go with one of those USB 8051s with built-in DAC. The Chinese have preprogrammed single-chip solutions for this --- search "SD card MP3 player" or similar (they can not only play MP3, but usually WAV, WMV, OGG, and a few others.)
 

Offline krho

  • Regular Contributor
  • *
  • Posts: 222
  • Country: si
Since anyway mass storage class requires FULL control of SD card, so you can't use the card while it is being accessed by PC, you would better just use a digital MUX, to switch the card between a USB card reader IC, and your MCU.
Card reader chips are available in USB high speed or super speed, while most MCU's built in USB can only do full speed. That's a lot time saving when transferring raw WAV files.
Know of any cheap and readily available even in small quantities? Microchip has a bunch of cheap! 2$ even in 10QTY e.g USB2244 Hi-Speed card readers, but you can't control any of the remaining GPIOs, where you could switch the mux when connected to the usb DATA port.
So on arm side only some LPC M3 remains for such task, SDIO + USB Hi-Speed which is too expensive for a device we are building.
 

Online JPortici

  • Super Contributor
  • ***
  • Posts: 3452
  • Country: it
But... 24bits? What for?

they actually achieve the dynamic range needed for 16 bits (check)
they are a cheaper and more available than equivalent 16 bit parts (check)
and I2S don't care as you send 32 bit words per channel anyway
 

Offline krho

  • Regular Contributor
  • *
  • Posts: 222
  • Country: si
GL3233 is not available at EU distributors, also using stolen firmware is a no go, sorry EU is no China where everybody copies everybody and gets away with it..
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
PIC32MZ may be worth a look ( the more recent EF ones with the less ridiculous errrata list). One big advantage is thay have tons of RAM -up to 512K -  you may need a fair bit for buffering USB lumpiness

They have 4-6 SPI ports which have I2S support ( I think on all of them), as well as HS USB Host, and come in sensible QFP packages.

I have never tried any PIC, maybe it's time? Any recommendation for a good devkit? http://store.digilentinc.com/chipkit-wi-fire-wifi-enabled-mz-microcontroller-board/ don't really need wifi though...
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13695
  • Country: gb
    • Mike's Electric Stuff
 I'd start with the Microchip ones as they will have example code ready to run on them - saves a lot of time for something complicated like USB if you can start with something that already does something.
Also makes it quick to evaluate performance.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 16561
  • Country: 00
Tanks for the reply  :)
On the phone so having a hard time trying to update the previous post. Here are some qualifiers:
I don't need a codec as I can parse the wav files to get the PCM.

Having it all pre-built doesn't hurt.

I want to be in control of the DACs as I'm going for phase coherency on the two streams.

I'm sure the DACs will be perfectly in phase on that chip.

Need at least 4GB storage.

You can attach an external SPI flash chip to that module, choose your own memory size:

http://www.ebay.com/itm/171764616814

Or get a modules with SD card reader. Have a poke around eBay, there's lots to choose from.

eg. http://www.ebay.com/itm/131577755212

Most of the adverts tell you the chipset on the board. You can use that info and google for datasheets, build your own module if you want to.
« Last Edit: January 19, 2017, 11:43:18 am by Fungus »
 

Online amyk

  • Super Contributor
  • ***
  • Posts: 8240
GL3233 is not available at EU distributors, also using stolen firmware is a no go, sorry EU is no China where everybody copies everybody and gets away with it..

If you buy their chip, you are actually giving them money. Why they will sue you if you are giving them profit?
The stolen firmware, I can bet my bottom dollar, is not written by any OEM. It is just standard firmware supplied by GL, with some string and VID/PID modified.
Or if you want to go the legit way, just give GL a call and they will probably supply all of these to you for free.
You are still required to pay SD license, but since you use it as an internal storage only, it is less likely anyone will find you violating SD license even if you don't pay for it.
To circumvent it completely, just market your product as if it uses MMC, which is royalty free and SD compatible.
This is why Chinese parts are so successful. Even if they officially supply info under NDA, they pay very little attention to you redistributing it, because it gives them more sales. They use NDAs to go after competitors, not customers.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf