Access to DSP instructions #6536
Replies: 1 comment
-
Posted at 2021-05-11 by @fanoush It is quite easy to expose such stuff as inline C code, anything that gcc compiler allows to compile including inline assembly can be used. You can also setup the compiler service on your computer to enable preprocessor or other compiler flags if needed see e.g. this https://gist.github.com/fanoush/9227640a869d78d69a799276dff0fb71 or a bit outdated (some patches no longer needed) guide here https://github.com/fanoush/ds-d6/wiki/Espruino-Inline-C Posted at 2021-05-11 by @gfwilliams As @fanoush says really - Inline C (http://www.espruino.com/InlineC) should 'just work' for you (with the existing, online compiler if you're using official boards). In fact I believe you could do inline assembler inside the Inline C, which should actually work pretty nicely. Posted at 2021-05-11 by mks Brillant, thanks fanoush! Thats very helpful info on your wiki page and thank you for your work on the dsd6 watches too - I've got a fw of the basic models and experiment a bit with them with espruino too when I get the odd chance. Posted at 2021-05-11 by @fanoush
yes it works, used it in floating point code to get/clear FP status register Posted at 2021-05-11 by mks Thanks Gordan! Yes I still have trusty my Pico's wayback from the kickstarter which are M4's so I think Posted at 2021-05-11 by mks Sorry one more question before I get too far along with this, on this page it warns that outputting at higher freq could max out the mcu, but Im not clear on what causes that limitation? If I wanted to generate say a sine wave with some modulation applied (say using DSP instructions to be as efficient as possible and using 16bit data which I think is what they operate on) could I still output 16bit at 44.1khz sample rate? Posted at 2021-05-11 by @gfwilliams
The timers used for the Waveform are a mix of a single hardware timer, plus software to handle the scheduling of multiple tasks (eg multiple waveforms, digitalPulse, software PWM, etc) on that one timer. If you do too much stuff then the processor just spends all its time servicing the interrupt and no time executing anything else! If you're doing a sine wave then you could just write that to a buffer and use Waveform on that buffer without need for DSP instructions though? If you're looking at doing realtime audio output and you're doing Inline C, then I would say you should actually just make your C code access the PWM output hardware directly - an example of doing that from JS is at https://www.espruino.com/STM32+Peripherals. Actually executing your code at a fixed interval could be a little more problematic, but probably the easiest method right now is:
And that should then be able to execute your function 441000 times a second without JS ever getting involved Posted at 2021-05-11 by mks Brill, thanks Gordan! Both those projects use the Teensy and its audio library and as the Teensy mcu is a M4 as well I had the idea of doing something along the same lines using Espruino as well. Thanks again for all the info that you and fanoush replied with, I think I have a good idea now of how to get started experimenting with this. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-05-10 by mks
Sorry this is probably a bit niche, but I was wondering if anyone has looked at using the DSP instructions?
I didn't even know the cortex-M4's had these instructions until I recently came across this audio library for the Teensy boards that uses them.
I'd love to be able to do some experimenting with these for audio projects from within Espruino too but I'm guessing it would be quite a lot of work to expose the DSP instructions from with Espruino?
Beta Was this translation helpful? Give feedback.
All reactions