<?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 to Drive RGB LED with PWM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21361/how-to-drive-rgb-led-with-pwm</link><description>Hi Nordic Team,
i am working on nrg52 to glow a RGB LED with white and Yellow colours. configured the RGB pins to three different Gpio (A2,A3,A4). 
 for this i am using PWM library example in which i can only configure 2 channel(2 pins) to drive PWM</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 28 Apr 2017 07:51:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21361/how-to-drive-rgb-led-with-pwm" /><item><title>RE: How to Drive RGB LED with PWM</title><link>https://devzone.nordicsemi.com/thread/83691?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2017 07:51:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3554db48-9d13-4b34-9971-4ca6dd653d83</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;The pins will be set to 0 voltage after you call &lt;code&gt;stop_LED_glow()&lt;/code&gt;, but if your RGB LED is &lt;strong&gt;active low&lt;/strong&gt;, the RGB LED will still glow. You can try to set the pins high in the stop_LED_glow function to test this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void stop_LED_glow(){

    nrf_drv_pwm_stop(&amp;amp;m_pwm0,false);
    nrf_drv_pwm_uninit(&amp;amp;m_pwm0);
    
    nrf_gpio_cfg_output(gLEDR);
    nrf_gpio_pin_set(gLEDR);
    
    nrf_gpio_cfg_output(gLEDG);
    nrf_gpio_pin_set(gLEDG);
    
    nrf_gpio_cfg_output(gLEDB);
    nrf_gpio_pin_set(gLEDB);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to Drive RGB LED with PWM</title><link>https://devzone.nordicsemi.com/thread/83690?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2017 04:45:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae360415-6425-4117-8feb-5f9ab33c2aca</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;void stop_LED_glow(){&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_pwm_stop(&amp;amp;m_pwm0,false);
nrf_drv_pwm_uninit(&amp;amp;m_pwm0);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;//here R,G,B are dutycycle&lt;/p&gt;
&lt;p&gt;void start_update_pwm(){&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;R = get_R();

G = get_G();

B = get_B();

for (int i=0; i&amp;lt;100; i++){

	reset_RGB_flag();

	update_pwm(i*R,i*G,i*B);

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;int main(void)
{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pwm_init();
while(1){
	start_update_pwm();
	nrf_delay_ms(1000);
	stop_LED_glow();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to Drive RGB LED with PWM</title><link>https://devzone.nordicsemi.com/thread/83689?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2017 13:06:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f658a6b-5b39-43d7-92f3-48a632170f31</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Is the last problem solved, where you able to set a yellow light on the RGB LED?&lt;/p&gt;
&lt;p&gt;Could you add in a comment how your &amp;quot;int main(void){...}&amp;quot; function looks like now?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to Drive RGB LED with PWM</title><link>https://devzone.nordicsemi.com/thread/83688?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2017 12:56:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aee6fcaf-cb93-4479-9a8d-bc89a7a880bb</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;once i have glow led i am unable to turn it off.
i have used these functions&lt;/p&gt;
&lt;p&gt;nrf_drv_pwm_stop(&amp;amp;m_pwm0,false);&lt;/p&gt;
&lt;p&gt;nrf_drv_pwm_uninit(&amp;amp;m_pwm0);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to Drive RGB LED with PWM</title><link>https://devzone.nordicsemi.com/thread/83687?ContentTypeID=1</link><pubDate>Thu, 27 Apr 2017 08:49:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24176efd-2182-4671-bf9f-afe4a017ea2c</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;If you are using the code in the post I linked to, you can try this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int main(void)
{
    
    pwm_init();
    
    update_pwm(m_top/2,m_top/2,0);

    while(1)
    {
        nrf_delay_ms(200);
    }

}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will set the RED(12) and GREEN(14) pins to 50% duty cycle, while the BLUE(15) pin will be 0 V.&lt;/p&gt;
&lt;p&gt;The PWM frequency is F(pwm) = base_clock/top_value, so with base clock NRF_PWM_CLK_4MHz and m_top 10000, the frequency will be ~400Hz.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to Drive RGB LED with PWM</title><link>https://devzone.nordicsemi.com/thread/83686?ContentTypeID=1</link><pubDate>Wed, 26 Apr 2017 10:23:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fdadb4a-7f2e-4525-801f-c1e5ae99c6b4</guid><dc:creator>saiteja</dc:creator><description>&lt;p&gt;hi i implemented PWM driver as you said but i am unable to control the duty cycle using PWM driver. even if i change sequence values in the function&lt;/p&gt;
&lt;p&gt;void nrf_drv_pwm_simple_playback(nrf_drv_pwm_t const * const p_instance,
nrf_pwm_sequence_t const * p_sequence,
uint16_t                   playback_count,
uint32_t                   flags);&lt;/p&gt;
&lt;p&gt;there is nochange. if i set set all sequence values to 0. still tricolor is displaying. how to control the duty cycle of each channel using PWM driver and how to set different values to each channel.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to Drive RGB LED with PWM</title><link>https://devzone.nordicsemi.com/thread/83685?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 11:35:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96c6e244-579f-4fb2-b36f-ef96937dd7b9</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You will need to create a new PWM instance to get a third channel with the PWM library. However, since you are using the nRF52832 I would recommend using the PWM driver instead(nrf_drv_pwm). This uses the PWM peripheral on the chip. Using the PWM library, app_pwm, on nRF52 you are wasting resources like timers and ppi and gpiote channels. Take a look at e.g. &lt;a href="https://devzone.nordicsemi.com/question/111054/why-am-i-having-problems-driving-an-rgb-led-with-pwm-from-nrf52/?answer=111752#post-id-111752"&gt;this devzone answer&lt;/a&gt; where a user configured the PWM driver for a RGB LED.&lt;/p&gt;
&lt;p&gt;To get a yellow light you need to drive the red and green pin. You should be able to find the appropriate frequency in the datasheet for the RGB LED you are using.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>