<?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>Using PWM for Audio with PPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110660/using-pwm-for-audio-with-ppi</link><description>Hi, 
 I want to implement an audio feature via the nRF52, using PWM, I want to play a audio sequence, changing the PWM definitions in a fast rate, and thus would like to use PPI, is there an example of something like that, is that even possible? 
 Thanks</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Apr 2024 11:33:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110660/using-pwm-for-audio-with-ppi" /><item><title>RE: Using PWM for Audio with PPI</title><link>https://devzone.nordicsemi.com/thread/481056?ContentTypeID=1</link><pubDate>Mon, 29 Apr 2024 11:33:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b41227e8-f584-4ccf-9b05-f801dd9e1fa2</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Eran&lt;/p&gt;
&lt;p&gt;It is certainly possible to do what you describe, yes. The question is what kind of sample rate and bitrate you need for the audio?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I implemented some code a while back to do music generation in the nRF52. This wasn&amp;#39;t for playback of audio files, but for sound generation, but the principle for setting up the PWM could be the same. You can have a look at the PWM setup &lt;a href="https://github.com/too1/ncs-melody/blob/master/src/main.c"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t use a timer to control the PWM over PPI, but rather relied on the&amp;nbsp;PWM module to advance the buffer after every PWM period. When doing this the sample rate will be dictated by the PWM top value. In my case I used a top value of 255 (for 8 bit audio), which in turn gives me a sample rate of&amp;nbsp;roughly 62kHz.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>