<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Suggestions audio processing (Input ADC, buffer, DSP, output PWM)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53215/suggestions-audio-processing-input-adc-buffer-dsp-output-pwm</link><description>Hello everyone, I am trying to implement audio processings algorithms with my nrf52DK. 
 What i need to do in order : 1- Sample my audio signal ( It will be guitar sound ,so fmax= 1200 Hz , let&amp;#39;s say fs=2400Hz ) 2- Push my sampe into a FIFO 3- Start my</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Oct 2019 09:00:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53215/suggestions-audio-processing-input-adc-buffer-dsp-output-pwm" /><item><title>RE: Suggestions audio processing (Input ADC, buffer, DSP, output PWM)</title><link>https://devzone.nordicsemi.com/thread/215231?ContentTypeID=1</link><pubDate>Wed, 16 Oct 2019 09:00:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47c676b6-64a1-4ac3-90fd-32c738400c77</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;You can use a separate TIMER to control the triggering of the PWM&amp;#39;s&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/pwm.html?cp=3_0_0_5_16_4_1#register.TASKS_SEQSTART-0-1"&gt;TASKS_SEQSTART[n]&lt;/a&gt;&amp;nbsp;task. This task starts outputting a sequence of PWM samples on the selected pin.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The idea is to find how much time is required to process the SAADC samples and update the PWM sequence in RAM, and then to fire the PWM regularly based on this offset in time. You can, for example, start the second TIMER on the SAADC&amp;#39;s END event, and have it trigger the PWM sequence start task after x amount of time.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;All TIMER&amp;#39;s run on the same clock source so there&amp;#39;s no drift between the individual TIMER peripherals.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You really have to read the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/pwm.html?cp=3_0_0_5_16"&gt;PWM — Pulse width modulation&lt;/a&gt;&amp;nbsp;spec and&amp;nbsp;&lt;a title="PWM driver" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrfx__pwm.html?cp=5_1_6_9_0_22_1"&gt;PWM driver&lt;/a&gt;&amp;nbsp;API ref, and try out the&amp;nbsp;&lt;a title="PWM Driver Example" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/pwm_hw_example.html?cp=5_1_4_6_22"&gt;PWM Driver Example&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Suggestions audio processing (Input ADC, buffer, DSP, output PWM)</title><link>https://devzone.nordicsemi.com/thread/215133?ContentTypeID=1</link><pubDate>Tue, 15 Oct 2019 15:44:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6be1232-869e-48d6-88fc-0b91d4405845</guid><dc:creator>stef</dc:creator><description>&lt;p&gt;OK i think i understood for 1 and 2, thanks a lot.&lt;br /&gt;Concerning the PWM, you advise me to&amp;nbsp;use a sequence (with the length of my buffer size for exemple), and to update the values periodically (inside the SAADC interrupt ? or using separate timer).&lt;br /&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Suggestions audio processing (Input ADC, buffer, DSP, output PWM)</title><link>https://devzone.nordicsemi.com/thread/215030?ContentTypeID=1</link><pubDate>Tue, 15 Oct 2019 10:54:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11d1beef-b6b6-4901-b05f-d512f419cbd4</guid><dc:creator>haakonsh</dc:creator><description>&lt;ol&gt;
&lt;li&gt;Use a TIMER to trigger the SAADC&amp;#39;s sample task. This is already set-up in the SAADC example in the SDK, you just need to change the frequency of the TIMER.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;The SAADC uses EasyDMA to transfer the sampled values into the buffer&amp;nbsp;with the address&amp;nbsp;written to&amp;nbsp;&lt;a title="  RESULT.PTR  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=3_1_0_36_10_40#register.RESULT.PTR"&gt;RESULT.PTR&lt;/a&gt;&amp;nbsp;of size&amp;nbsp;&lt;a title="  RESULT.MAXCNT  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=3_1_0_36_10_41#register.RESULT.MAXCNT"&gt;RESULT.MAXCNT&lt;/a&gt;. With only one channel enabled you the&amp;nbsp;&lt;span&gt;EVENTS_END will fire after you have triggered the sample task&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;#39;n&amp;#39; times, and &amp;#39;n&amp;#39; samples have been transferred to RAM, where &amp;#39;n&amp;#39; is&amp;nbsp;&lt;a title="  RESULT.MAXCNT  " href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=3_1_0_36_10_41#register.RESULT.MAXCNT"&gt;RESULT.MAXCNT&lt;/a&gt;.&amp;nbsp;&lt;br /&gt;If you enable more than one channel each triggered sample task will take a number of samples equal to the number of enabled channels.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Yes, you can do that. &lt;br /&gt;But just using a few samples in a sequence will offload your CPU quite a bit, without sacrificing the latency too much. If you&amp;#39;re going to do any sort of DSP on the sampled signals you will probably operate on fixed-width buffers anyways so you might as well&amp;nbsp;use a PWM sequence for playback and save the overhead of manually updating each sample at 2.4kHz.&amp;nbsp;&amp;nbsp;If you&amp;#39;re going to have any BLE activity concurrently with PWM you will need to use sequencing or else you&amp;#39;ll drop some of the PWM samples.&amp;nbsp;&lt;br /&gt;With buffer size of 24 you&amp;#39;ll get 10ms latency&amp;nbsp;at a sample rate of 2.4kHz, add a few ms of DSP per buffer and you should still be under 20ms, who I believe is deemed good enough for most audio application.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>