<?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>Bug in the 16-bit PWM implementation in dimming examples</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42504/bug-in-the-16-bit-pwm-implementation-in-dimming-examples</link><description>Hi, 
 Experimental dimming examples contain a 16 bit PWM implementation. I added the Enocean switch functionality to the dimming server example to control the LED on the board with the app as well as with the switch. I was using the 16-bit PWM function</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 13 Feb 2019 14:43:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42504/bug-in-the-16-bit-pwm-implementation-in-dimming-examples" /><item><title>RE: Bug in the 16-bit PWM implementation in dimming examples</title><link>https://devzone.nordicsemi.com/thread/170932?ContentTypeID=1</link><pubDate>Wed, 13 Feb 2019 14:43:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:468eac10-86ed-462a-8060-913d796c2979</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Any update on the issue?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in the 16-bit PWM implementation in dimming examples</title><link>https://devzone.nordicsemi.com/thread/167181?ContentTypeID=1</link><pubDate>Tue, 22 Jan 2019 16:23:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85952181-17e6-4c6d-8cc1-0bda9bdc5143</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;Hi Joakim,&lt;/p&gt;
&lt;p&gt;Were you able to reproduce this issue and check what the exact reason might be?&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in the 16-bit PWM implementation in dimming examples</title><link>https://devzone.nordicsemi.com/thread/166369?ContentTypeID=1</link><pubDate>Thu, 17 Jan 2019 21:20:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fd73556-73b1-4c71-ba95-70f450af69bf</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;&lt;span&gt;Hey! Thanks&amp;nbsp;&lt;/span&gt;&lt;span&gt;And no, its not a trace issue, the&amp;nbsp;&lt;/span&gt;&lt;span&gt;CURRENT_LIGHT_INTENSITY variable gets affected and it&amp;nbsp;doesn&amp;#39;t reach same max values every time... and the &amp;quot;Jumps&amp;quot; are quite&amp;nbsp;random too, so are we leaning towards some BLE&amp;nbsp;transmission, interruptions or something related...?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in the 16-bit PWM implementation in dimming examples</title><link>https://devzone.nordicsemi.com/thread/166357?ContentTypeID=1</link><pubDate>Thu, 17 Jan 2019 18:33:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a98044c0-e575-4210-8748-d95459c2f69e</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;Or it could just be a limitation of the Trace.&lt;/p&gt;
&lt;p&gt;The Trace is not good for spitting out very large volumes of stuff;&amp;nbsp; it is quite easily overloaded - which could explain the &amp;quot;gaps&amp;quot; that you see...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in the 16-bit PWM implementation in dimming examples</title><link>https://devzone.nordicsemi.com/thread/166351?ContentTypeID=1</link><pubDate>Thu, 17 Jan 2019 17:44:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffd202d5-228b-4f91-b86e-800a05a22bdb</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Looks like you have another process interrupting the trace; instead of 5 or 6 increment in the trace timestamp it jumps from (first example) 1052181 to 1052360&amp;nbsp; = 179&amp;nbsp;which is about 32 light levels or suspiciously close to the actual light levels &amp;quot;jumped&amp;quot; (19403-19371)=32. If a delay of 1mSec fixes the &amp;quot;jump&amp;quot; then you can assume that the interrupting process takes less than 1mSec to complete; perhaps it&amp;#39;s a BLE transmission, or a serial port interrupt for a trace debug message .. ie it&amp;#39;s not a light level jump but a jump in trace messages&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in the 16-bit PWM implementation in dimming examples</title><link>https://devzone.nordicsemi.com/thread/166343?ContentTypeID=1</link><pubDate>Thu, 17 Jan 2019 16:59:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1347b6cb-ddf3-4bf9-97ad-077689417fbf</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Below is the code where I am recording the &amp;quot;Current Dimming&amp;quot; values:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;while (m_dim &amp;amp;&amp;amp; On_OFF)
{
    if(m_dim_state == 0)
    {
		CURRENT_LIGHT_INTENSITY++;
		if(CURRENT_LIGHT_INTENSITY &amp;gt; (UINT16_MAX/2))
        {
			m_dim_state = 1;
            m_dim = false;
            break;
		}
	}
    else if(m_dim_state == 1)
    {
		CURRENT_LIGHT_INTENSITY--;
        if(CURRENT_LIGHT_INTENSITY &amp;lt; 0)
        {
			nrf_delay_ms(10);
            while (app_pwm_channel_duty_set2(&amp;amp;PWM0, 0, 0) == NRF_ERROR_BUSY);
            CURRENT_LIGHT_INTENSITY = 0;
            m_dim_state = 0;
            m_dim = false;
            break;
	    }
    }
    while ( app_pwm_channel_duty_set2(&amp;amp;PWM0, 0, CURRENT_LIGHT_INTENSITY) == NRF_ERROR_BUSY);
    
    __LOG(LOG_SRC_APP, LOG_LEVEL_ERROR, &amp;quot;Current dimming: %d\n&amp;quot;, CURRENT_LIGHT_INTENSITY);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The code for the function that sets the duty cycle for PWM is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret_code_t app_pwm_channel_duty_set2(app_pwm_t const * const p_instance,
                                  uint8_t channel, app_pwm_duty_t duty)
{
    uint16_t ticks = ((uint32_t)(duty) * m_pwm0_max) / UINT16_MAX;
    return app_pwm_channel_duty_ticks_set(&amp;amp;PWM0, 0, ticks);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As I said, I added EnOcean functionality, the &amp;quot;m_dim&amp;quot; indicates switch press; &amp;#39;On_OFF&amp;#39; indicates LED On/Off; &amp;quot;m_dim_state&amp;quot; indicates increase/ decrease of intensity and CURRENT_LIGHT_INTENSITY indicates the level.&lt;/p&gt;
&lt;p&gt;The image that was posted in the question was taken when I was trying to increase the intensity of the LED. The jumps are also vague as the jump will not be at the same value next time and also the amount of jump is always different.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;More or less, it can be said that, when I loop through the values from 0 to 32767, I observe numerous jumps and rarely catch the exact limits(0,32767)&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bug in the 16-bit PWM implementation in dimming examples</title><link>https://devzone.nordicsemi.com/thread/166290?ContentTypeID=1</link><pubDate>Thu, 17 Jan 2019 14:47:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3c2c362-5af0-48c9-98cf-7fde88be80c0</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Where and how did you add these logs to output the &amp;quot;Current Dimming&amp;quot;?&lt;/p&gt;
&lt;p&gt;The three highlighted outputs (Current dimming: 19402/19410/19491) that stands out from the rest is always where the jump in value happens. &lt;br /&gt;Are these values collected the same way as the rest? &lt;br /&gt;Why does the output look different?&lt;/p&gt;
&lt;p&gt;Maybe you could upload the code where this is implemented?&lt;/p&gt;
&lt;p&gt;Best regards, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>