Author Topic: Need help choosing microcontroller, going crazy (two channels wav playback)  (Read 14089 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
Just to get the idea of what I'm after I'll post this here:


I will make at least 100 units so I'm not looking to cobble some modules together. My ultimate goal is to have zero wire harnesses and to minimize manual labor to attaching the display and the ~20 screws for the connectors and panels onto the enclosure. I'll rather spend a few dollars in more expensive parts that fit my design criteria than spend a few minutes cutting and soldering cables - per board. I'll rather make three PCB revisions than having to do manual bodges on everything.

Thanks for all the input guys! Thanks to your input I've got a proto now.
:)
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 28013
  • Country: nl
    • NCT Developments
Did you look at NXP's LPC1700 series? AFAIK these should fit the bill. USB host capability (LUFA USB stack provided by NXP), real SD card interface and I2S interface. Ofcourse it has a DMA engine to offload the CPU from dealing with all the data transfers.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
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.

Just spent half an hour pulling down MPLAB X and Harmony and I've got to say it's looking good! For some reason I've always shied away from PICs but I see that's probably been a mistake.
About to press order on this; http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=DM320007
Would be very grateful if someone could say "do it" or "why don't you try [this] instead?"!

So far it seems like a nice environment, good documentation and all in all a nice powerful package!

EDIT: No, I've not had a close look at the NXP. I like STM and apparently MPLAB is very nice too! So I think the first decision has been made for me. It will be either an STM32F4 or a PIC32mz :)
« Last Edit: January 19, 2017, 09:55:53 pm by alexanderbrevig »
 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
Do It: PIC32MZ uses MIPS32 core which is a very nice but old microarchitecture to use (at least with ASM).
Don't do it: You are at the mercy of Microchip who are possibly the only vendor using a MIPS32 core whereas the STM32 has many upgrade, downgrade possibilities and heaps of other vendors with similar Cortex M microcontrollers.
Having said this, before I moved to 32bit Cortex M, I was using Atmel AVRs and of course was locked in for years as no other vendors make an AVR equivalent.
At the end of the day, which chip will let you do everything you want to do (or at least not prevent you from doing so)?
Me personally, I chose STM32 for a similar project because I had them here, they are very cheap, easy to get, tons of examples and resources and I have written a collection of libraries that I reuse and also especially because I know there are future chips coming that will be an easy upgrade path (STM32H7 400MHZ Cortex M7), I did also consider PIC32MZ but the long ISR latency and DEV board price scared me away.
On the down side to STM32, I find the examples are somewhat buggy and or incomplete and the community forum is very quiet.
You decide :)
« Last Edit: January 20, 2017, 06:47:12 am by bobaruni »
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13987
  • Country: gb
    • Mike's Electric Stuff
Do It: PIC32MZ uses MIPS32 core which is a very nice but old microarchitecture to use (at least with ASM).
Don't do it: You are at the mercy of Microchip who are possibly the only vendor using a MIPS32 core whereas the STM32 has many upgrade, downgrade possibilities and heaps of other vendors with similar Cortex M microcontrollers.
"At the mercy" how exactly? Microchip have the best record in the industry of not obsoleting parts, and also have several pin-compatible variants to provide alternatives if there is a short-term supply issue.
The core does nit matter at all - it's all about the IO. There's more similarity between 16 and 32 bit PICs than ARM devices from different manufacturers.

Quote
I did also consider PIC32MZ but the long ISR latency and DEV board price scared me away.
If devboard cost is a factor in choosing a chip you are  not a serious user.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Thanks for the input guys!
I see no direct objections on my choice of dev board so it's now ordered!

Which part I'll choose for this project is still undecided but I figure I should at least give the PIC a fair chance. Along my previous statements I might as well add; I'll rather spend tenfold on a devkit that works from the get-go, rather than a cheapo that needs a few hours of frustration. It's still true - time is money!

All that said, I like the excuse to get a new dev kit. Who doesn't?  ;)
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3525
  • Country: it
whereas the STM32 has many upgrade, downgrade possibilities and heaps of other vendors with similar Cortex M microcontrollers.
as if you didn't have to rewrite almost all the code anyway because peripherals behave differently, are named differently and use a totally different API (USB for example)
Quote
I did also consider PIC32MZ but the long ISR latency and DEV board price scared me away.
as if cortex didn't have its fair amount of interrupt latency and pipeline interlock too
Also dev tools are always pricey. Talking about boards with everything already mounted and working, with a working software already on.. and you just write your routines while the hardware is being designed. IMHO Microchip excel at those, their example just works, provided you have the correct compiler installed. The same can't be said for ST and i think arm in general. Go on, open an example project from ST and tell me how it went.

If you meant that microchip doesn't have a simple board with MCU and onboard programming in the 10-20 euro range (maybe even 'duino compatible for the joy of makers) you are wrong. Olimex makes those (wish there was some cheaper/simpler like the VLDiscovery but you can't have everything)
« Last Edit: January 20, 2017, 10:14:19 am by JPortici »
 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
Do It: PIC32MZ uses MIPS32 core which is a very nice but old microarchitecture to use (at least with ASM).
Don't do it: You are at the mercy of Microchip who are possibly the only vendor using a MIPS32 core whereas the STM32 has many upgrade, downgrade possibilities and heaps of other vendors with similar Cortex M microcontrollers.
"At the mercy" how exactly? Microchip have the best record in the industry of not obsoleting parts, and also have several pin-compatible variants to provide alternatives if there is a short-term supply issue.
The core does nit matter at all - it's all about the IO. There's more similarity between 16 and 32 bit PICs than ARM devices from different manufacturers.

Quote
I did also consider PIC32MZ but the long ISR latency and DEV board price scared me away.
If devboard cost is a factor in choosing a chip you are  not a serious user.
A serious user? or perhaps I can do the same thing with something that is 1/10th the cost.
The cost or how much money I have has no bearing on how serious I am.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13987
  • Country: gb
    • Mike's Electric Stuff
Do It: PIC32MZ uses MIPS32 core which is a very nice but old microarchitecture to use (at least with ASM).
Don't do it: You are at the mercy of Microchip who are possibly the only vendor using a MIPS32 core whereas the STM32 has many upgrade, downgrade possibilities and heaps of other vendors with similar Cortex M microcontrollers.
"At the mercy" how exactly? Microchip have the best record in the industry of not obsoleting parts, and also have several pin-compatible variants to provide alternatives if there is a short-term supply issue.
The core does nit matter at all - it's all about the IO. There's more similarity between 16 and 32 bit PICs than ARM devices from different manufacturers.

Quote
I did also consider PIC32MZ but the long ISR latency and DEV board price scared me away.
If devboard cost is a factor in choosing a chip you are  not a serious user.
A serious user? or perhaps I can do the same thing with something that is 1/10th the cost.
The cost or how much money I have has no bearing on how serious I am.
The cost of the devboard is insignificant compared to other costs for anything but a hobbyist project.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: alexanderbrevig, JPortici

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 17203
  • Country: 00
If devboard cost is a factor in choosing a chip you are  not a serious user.

Or maybe they are not a serious chip seller.

 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
The cost of the devboard is insignificant compared to other costs for anything but a hobbyist project.
You're absolutely right, but picture a scenario where you design something that you would like to share with the wider community, shouldn't you base it on a board that many more people can afford?
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3525
  • Country: it
a devboard will always cost less than me having to spend a morning researching for one, an afternoon assembling one and the eventual one two three following days of troubleshooting

a devboard =/= a chip with a power supply and programmer on a breakout board. and there are these, cheaper ones for microchip. again, look at olimex
« Last Edit: January 20, 2017, 10:18:20 am by JPortici »
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3525
  • Country: it
If devboard cost is a factor in choosing a chip you are  not a serious user.
Or maybe they are not a serious chip seller.

:-DD
that's a good one, i genuinely laughed
 

Offline Fungus

  • Super Contributor
  • ***
  • Posts: 17203
  • Country: 00
If devboard cost is a factor in choosing a chip you are  not a serious user.
Or maybe they are not a serious chip seller.
:-DD
that's a good one, i genuinely laughed

OK, that was the wrong word. I meant everything else they do will also be a paid service. They won't be interested in you unless you're a "serious" customer ordering a million chips on a corporate account.
 

Offline Howardlong

  • Super Contributor
  • ***
  • Posts: 5408
  • Country: gb
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...

I have that WiFire board. For serious projects, you'll want to populate the ICD header and use a debugger with it: out of the box it just offers the ability to self-upload flash images. Although it is supported by Harmony (which you have little choice but to use if you're using USB) and there is a board support package for it, there are not many examples at present that actually use it, and certainly not for all those peripherals. It's good hardware with plenty of peripherals, but lacks an onboard debugger.

Another option might be the very recently shipping PIC32MZ EF Curiosity board DM320104 but you'll possibly want the audio daughter board and a MikroBus SD card adapter.

I would take a look at the Harmony help file and check which boards support which example applications. By far the best supported board is the PIC32MZ EF starter kit DM320007 (or DM320007-C which has the crypto enabled), which includes and integrated debugger and host, device and OTG HS USB. You will want some means of adding an SD card, with a MEB II DM320005-2 being the best supported. Unfortunately, neither the PIC32MZ SK nor the MEB II are cheap options, but they will be the easiest to get yourself up and running as there is already an application written for this combination for audio and SD card access. If you value your time, PIC32MZ EF SK + MEB II is the way to go as other alternatives will mean a fair bit of learning especially if you are new to Harmony.

BTW, PIC32MZ doesn't support SD card SDIO mode, it's SPI mode only.
 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
"At the mercy" how exactly? Microchip have the best record in the industry of not obsoleting parts, and also have several pin-compatible variants to provide alternatives if there is a short-term supply issue.
The core does nit matter at all - it's all about the IO. There's more similarity between 16 and 32 bit PICs than ARM devices from different manufacturers.
Again, you are absolutely right, It doesn't matter with modern compilers but I still like to get my hands dirty and code in pure ASM and the MIPS32 core is my favorite to this day.
It seems I have ruffled some feathers by suggesting STM32 over PIC32MZ, perhaps I failed to mention I use both, as well as NXP Cortex M, Kinetis Cortex M, AVR, PIC16....and so on
All I'm saying is that in ONE particular application which is very similar to the OP's, I chose the STM32 as it ticked more boxes than any other chips at the time I started the design process.
My current thinking is to also try the Cypress PSOC 5LP as I have one here and have never used it and would like to explore the CPLD-like programmable logic which would be nice for SPDIF In / Out.
It's my opinion only as I'm sure your/others criteria/specifications and allegiance to a particular vendor (I don't have one) may be different.
« Last Edit: January 20, 2017, 10:40:26 am by bobaruni »
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 28013
  • Country: nl
    • NCT Developments
The same can't be said for ST and i think arm in general. Go on, open an example project from ST and tell me how it went.
ST is a pretty bad example when it comes to compatibility between the various devices which has turned me away from ST's ARM controllers every time. NXP's LPC series ARM controllers is much better in that respect so you don't need any HAL to make your code portable between devices.

Regarding dev boards: I always liked to roll my own based on schematics from existing boards. That way I add things I like and catch things which can go wrong on a prototype early.
« Last Edit: January 20, 2017, 10:36:44 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
The same can't be said for ST and i think arm in general. Go on, open an example project from ST and tell me how it went.
ST is a pretty bad example when it comes to compatibility between the various devices which has turned me away from ST's ARM controllers every time. NXP's LPC series ARM controllers is much better in that respect so you don't need any HAL to make your code portable between devices.

Regarding dev boards: I always liked to roll my own based on schematics from existing boards. That way I add things I like and catch things which can go wrong on a prototype early.
Yes I like to roll my own except for when the package is BGA....just can't do it....yet.
Speaking of NXP, the LPC Link 2 is a pretty unique board with it's 80MSPS 12 bit ADC built in, nice little oscilloscope project for a little over $25
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3525
  • Country: it
If devboard cost is a factor in choosing a chip you are  not a serious user.
Or maybe they are not a serious chip seller.
:-DD
that's a good one, i genuinely laughed

OK, that was the wrong word. I meant everything else they do will also be a paid service. They won't be interested in you unless you're a "serious" customer ordering a million chips on a corporate account.

as for lately, i'd tend to agree with you. though this still happens: a genuine programmer breaks down? out of warranty? nonsense. a new one will be delivered to you for free.
just an example..
bug aknowledgement and responsiveness is on par if not better with other manufacturers i use

let me remind you of the st forum, i find the microchip one to be better
or nxp community.. official nxp support will tell you to first post your question to the community (where their account will only post automatically generated bullshit comments of reading the FAQs)
and then you're on your own, that platform is just awful.
« Last Edit: January 20, 2017, 10:47:28 am by JPortici »
 

Offline bobaruni

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
let me remind you of the st forum
There is a new forum It's still rubbish and the links to other forum replies are all broken, absolutely useless.
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Allright people! I've come to a decision for now  :)
I've made the choice to go STM32 for this one but I'll definitively check out that PIC32MZ*EF for my next educational project!

The rough layout has started:


I'm well on my way, and will continue to document my process.
The blog is mostly for myself. Just in case anyone has interest: https://livearmada.wordpress.com/ there's also a post there about all this mcu selection stuff!
 
The following users thanked this post: bobaruni

Offline hans

  • Super Contributor
  • ***
  • Posts: 1688
  • Country: nl
The STM32F4 is more than capable of doing this. I made a dual stereo USB soundcard with the STM32F411, which is a simpler slower chip without the LCD and lacks some of the interconnectivity peripherals. It is more than capable of driving both audio channels, as well as doing software mixing of a center and a subwoofer (IIR low-pass filter at 48kHz) channel, using hardware floating point. I haven't fussed with the USB enumeration profiles to make do some more sophisticated stuff I had planned, but it goes to show there is plenty of room to spare.

Moreover, the I2S peripheral also has DMA which I haven't used yet. So this chip is also serving 4x 48kHz interrupts at this moment, which is very wasteful but it works.

It shows how much room is left for processing other stuff like LCDs, even at 100MHz. But if you can budget in a STM32F42x or STM32F43x, you can do some wicked stuff at 180MHz and it's DMA2D engine.

You don't need much buffers at all for USB audio. Audio is sent using USB isochronous transfers, which are only 192 bytes (2 channels x 16-bit x 48 samples) in size in my case. 44.1kHz is annoying to deal with because it's a non-multiple of 1000, so rather pick 48kHz. The USB sends Isochronous packets at 1kHz and synchronizes it using SOF tokens on the bus. SOF is a cheap 1kHz time base for USB, and is used to latch the buffer to the audio codec. This is useful because there will always be clock differences even when using the I2S PLL, and if your word sample frequency is off by 1-2Hz that means you're dropping (or interpolating) 1-2 samples each second. For me this is inaudible and just a consequence of dealing with USB.

I've first tried finishing off the buffer and then swapping to the new buffer at the audio codec level, but that had some audio distortion that only popped up every minute or so. I think it was because the sample clock was a few Hz to slow, and so eventually it was 1 complete buffer of 48 samples behind which was eventually completely dropped.

I can say the ST code examples were helpful, but because I was in a hurry I also borrowed some parts of this project
« Last Edit: January 31, 2017, 09:30:42 am by hans »
 

Offline alexanderbrevigTopic starter

  • Frequent Contributor
  • **
  • Posts: 700
  • Country: no
  • Musician, developer and EE hobbyist
    • alexanderbrevig.com
Hi there hans!

Cool project you've got going there :)


Just in case it's unclear. I'm not streaming off of USB. It's off of the SD card. Also I'll be using STM32F103 which looks to be about 50% cheaper :)
I was concerned about that 44.1 thing myself, but I see they have a 9 bit prescaler named 44K (I've checked, it is actually 44.1) so I'm hoping I'll be in good hands. If not I could always demand 48k but I'd prefer not to.

Jitter won't be too much of an issue for me as I can get samples on demand. I will select a very precise oscillator (can't remember the different ones) but I want be as close to 44.1 as I can.

DMA is a thing I know I'll have to use, but up until now I really have not had any hand-on playtime with it. I'm hoping it's not as scary as I feel it is  :scared:
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf