<?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>Sampling ADC synced with PWM through PPI</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34744/sampling-adc-synced-with-pwm-through-ppi</link><description>Hi all, 
 I am newbie with nordic, and I need some help. 
 I am using nRF52832 with softdevice. 
 I need to generate a 128 kHz clock signal (PWM pulses with 128kHz frequency, duty cycle 50%,) and to sample Analog input at the same frequency (128 kHz)</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 May 2018 13:44:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34744/sampling-adc-synced-with-pwm-through-ppi" /><item><title>RE: Sampling ADC synced with PWM through PPI</title><link>https://devzone.nordicsemi.com/thread/133443?ContentTypeID=1</link><pubDate>Fri, 25 May 2018 13:44:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce74063e-91d9-4c08-92d1-63ee7d40b327</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I saw your other case &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/34631/sample-adc-synced-with-pwm"&gt;here&lt;/a&gt;. I suggest you do as &lt;a href="https://devzone.nordicsemi.com/members/holmgren"&gt;Rune Holmgren&lt;/a&gt; suggested, to use the bare metal implementation of the PWM.&lt;/p&gt;
&lt;p&gt;I attached a project that uses the TIMER peripheral with the GPIO peripheral to generate a PWM with two channels. If you only need one, just remove everything that looks like it belongs to PWM1, and not PWM0.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-1da9501d500a402cb915cbb92e6ba083/ppi_5F00_double_5F00_channel_5F00_pwm.zip"&gt;devzone.nordicsemi.com/.../ppi_5F00_double_5F00_channel_5F00_pwm.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you only need one PWM signal, I suggest that you remove the PWM1, and use the FORK command to attach the SAADC sampling to the event:&lt;/p&gt;
&lt;p&gt;(uint32_t)&amp;amp;NRF_TIMER3-&amp;gt;EVENTS_COMPARE[PWM0_TIMER_CC_NUM];&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Just like the PWM1&amp;nbsp;TASK_SET is forked.&lt;/p&gt;
&lt;p&gt;But you must remove the PWM1 for this, since you can only have one fork per PPI channel.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It should look something like:&lt;/p&gt;
&lt;p&gt;NRF_PPI-&amp;gt;FORK[PWM0_PPI_CH_B].TEP = (uint32_t)&amp;amp;NRF_SAADC-&amp;gt;TASKS_SAMPLE;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>