[sdiy] DSP coding (was: how you got started with your current µC? (was: Re: Most common ICs))
rsdio at audiobanshee.com
rsdio at audiobanshee.com
Fri Sep 25 22:46:34 CEST 2015
On Sep 20, 2015, at 2:25 PM, Richie Burnett <rburnett at richieburnett.co.uk> wrote:
>
> Thomas Strathmann wrote:
>> BTW, how is the situation of using C on PICs (or dsPICs for that matter)?
>
> As others have said C works fine for basic PICs.
>
> However, I do all my DSP work in assembler, so I have no idea how well C works for DSP algorithms operating in the MAC unit with extended precision accumulators, pre- / post-incrementing pointers, accumulator write-back, and things like saturation arithmetic. Personally, I just take care of it directly in assembler. It's not a problem. You do have to learn about the architecture of the specific processor, and the resulting code is not as portable to another platform, etc... but this degree of familiarity and detailed optimisation can be the difference between an application being achievable or not achievable when it comes to the tight loops used for intensive FIR or IIR filtering.
>
> -Richie
Glad to see this topic raised.
Interestingly enough, the Texas Instruments TMS320 C compiler manual has examples showing the special ordering of C code statements to take advantage of the chip's MAC instructions with automatic pointer address updates and such. Thus, it's possible to get basic access to the higher computing power, but I don't recall any way to control the saturation mode (which is very useful).
A good DSP vendor will have common algorithms coded in assembly language as examples or open source libraries. These can be tweaked or used as a learning tool for your own, custom processing. Some are a little buggy.
I'm currently trying to figure out the transition from Cortex-M3 to Cortex-M4 with regard to the CMSIS DSP libraries. Rumor on the street is that the assembly language version for the M3 is as fast as the C language version for the M4, begging the question of how fast the assembly language version for the M4 would be if it were written. I have no idea whether it's already available and I just haven't found it or if it's in progress or they've just dropped the ball. I suppose I could optimize the DSP routines for M4 myself using assembly language, but the promise of a popular library like CMSIS is that everyone doesn't have to roll their own fast ARM code.
Basically, I wish that more people were aware of the significant speed increases that are possible when using a special purpose DSP chip, especially in assembly, instead of using a general purpose processor in any high level language. The DSP can be hundreds of times faster in terms of cycles, and will often use less energy for the same results - which translates into longer battery life and less heat.
The Soundplane is based on the TMS320VC5500, and performs 16,000 FFTs of 128 points every second. It also performs USB operations using standard C coding to pack all of the data efficiently. The mix of assembly and C allows the whole thing to be powered by the USB cable and still achieve extremely low latency and fast updates. The Soundplane doesn't actually generate audio, but I hope it's on-topic since it's a control surface for sound.
Brian Willoughby
Sound Consulting
More information about the Synth-diy
mailing list