<?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>How can i add more pwms in nrf52840 example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/115585/how-can-i-add-more-pwms-in-nrf52840-example</link><description>I am working on CAF example Module and it has 4 pwms in overlay file. 
 1. Is it possible to add another PWM? 
 2. Is there any limit to number of PWMs and number of channels i can use on each pwm? 
 3. Can you please point me to any resource available</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Oct 2024 07:49:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/115585/how-can-i-add-more-pwms-in-nrf52840-example" /><item><title>RE: How can i add more pwms in nrf52840 example</title><link>https://devzone.nordicsemi.com/thread/507058?ContentTypeID=1</link><pubDate>Mon, 21 Oct 2024 07:49:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4322224d-e0ae-4474-9a75-4a76f9583ddc</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Answers to your questions&lt;/p&gt;
[quote user="akay47"]1. but i believe those are 4 unique PWMs where each PWM can has 4 different channels.[/quote]
&lt;p&gt;Yes,&amp;nbsp; Can see instances &lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf52840/page/pwm.html#ariaid-title6"&gt;here&lt;/a&gt;&amp;nbsp;and four channel count which can be used in the nrfx_pwm_config as below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfx_pwm_config_t const pwm_config = {
    .output_pins = { 22,                      // Channel 0 pin (set to your desired GPIO pin)
                     NRF_PWM_PIN_NOT_CONNECTED, // Channel 1
                     NRF_PWM_PIN_NOT_CONNECTED, // Channel 2
                     NRF_PWM_PIN_NOT_CONNECTED }, // Channel 3
                     ....&lt;/pre&gt;&lt;/p&gt;
[quote user="akay47"]3. The only thing channels on a single PWM can have different is Duty cycle?[/quote]
&lt;p&gt;Yes, that is correct. In the nRF52840 PWM peripheral, all channels within a single PWM instance share the same frequency and period (top value), but they can have individual duty cycles&lt;/p&gt;
[quote user="akay47"]Now i want to modify that example to add more channels in a single PWM Instance so i can provide those signals to an RGB LED with different duty cycles on 3 channels of a single PWM Instance for color mixing. I could not find any example on how to do that[/quote]
&lt;p&gt;Yes, Something like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfx_pwm_t pwm_instance = NRFX_PWM_INSTANCE(0); // Use PWM instance 0

nrfx_pwm_config_t const pwm_config = {
    .output_pins = { X,   // Red LED pin (Channel 0)
                     Y,   // Green LED pin (Channel 1)
                     Z,   // Blue LED pin (Channel 2)
                     NRF_PWM_PIN_NOT_CONNECTED }, // Channel 3 is not used
    .irq_priority = APP_IRQ_PRIORITY_LOWEST,
    .base_clock   = NRF_PWM_CLK_1MHz,  // 1 MHz base clock
    .count_mode   = NRF_PWM_MODE_UP,
    .top_value    = 1000,              // Adjust for PWM frequency (e.g., 1 kHz)
    .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
    .step_mode    = NRF_PWM_STEP_AUTO
};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can i add more pwms in nrf52840 example</title><link>https://devzone.nordicsemi.com/thread/506718?ContentTypeID=1</link><pubDate>Thu, 17 Oct 2024 12:24:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:737d8d47-36ea-4a1d-951b-d99b8aa11a3b</guid><dc:creator>akay47</dc:creator><description>&lt;p&gt;Thank you for your response. I am working on CAF module example and it has 4 pwm configured. correct me if i am wrong, &lt;br /&gt;1. but i believe those are 4 unique PWMs where each PWM can has 4 different channels.&lt;br /&gt;2. Each PWM can be set to a unique frequency and all channels of that PWM will share same frequency?&lt;br /&gt;3. The only thing channels on a single PWM can have different is Duty cycle?&lt;br /&gt;4. Now i want to modify that example to add more channels in a single PWM Instance so i can provide those signals to an RGB LED with different duty cycles on 3 channels of a single PWM Instance for color mixing. I could not find any example on how to do that.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can i add more pwms in nrf52840 example</title><link>https://devzone.nordicsemi.com/thread/506714?ContentTypeID=1</link><pubDate>Thu, 17 Oct 2024 12:10:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5593405f-6c2a-444c-b2f3-844ed3df34f7</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;1. Yes, that should be possible.&lt;/p&gt;
&lt;p&gt;2. There are 4 PWM channels, and 4 PWM instances available on the nRF52840, so there are a total of 16 pins can be used for PWMs, but with some limitations for the ones sharing instances/channels.&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf52840/page/keyfeatures_html5.html"&gt;https://docs.nordicsemi.com/bundle/ps_nrf52840/page/keyfeatures_html5.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;3. The product specs and the&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/"&gt;https://docs.nordicsemi.com/&lt;/a&gt;&amp;nbsp;in general should be helpful. Also, the &lt;a href="https://academy.nordicsemi.com/"&gt;nRF Connect SDK courses on the DevAcademy&lt;/a&gt; should be of use.&lt;/p&gt;
&lt;p&gt;4. I&amp;#39;m not sure I understand your question here. What is the use case you need this for exactly?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>