<?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>Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/43844/initial-spike-with-pwm-implementation</link><description>Hi, 
 I am using a PWM to control the output of an LED driver and I am implementing a soft_on function when powering ON the driver, so we have a start_PWM function that looks like this: 
 
 static void start_PWM(void)
{
// PWM stuff
 app_pwm_config_t</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Feb 2019 08:25:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/43844/initial-spike-with-pwm-implementation" /><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/173391?ContentTypeID=1</link><pubDate>Thu, 28 Feb 2019 08:25:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9aba1169-c615-4b90-a25a-c06832baeeea</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;All IO pins will be&amp;nbsp;configured with their default configuration (input - disconnect) after a reset. That is, all reset types except &amp;quot;Wakeup&amp;nbsp;from System OFF reset&amp;quot;.&amp;nbsp;So unless you use System OFF, I&amp;#39;m not sure why you see the spike.&lt;/p&gt;
&lt;p&gt;From the PS:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-d631e2c758e547c5b51e5f03dd6ad502/pastedimage1551342034033v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/173313?ContentTypeID=1</link><pubDate>Wed, 27 Feb 2019 18:14:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1711a34-bb55-4c3e-8e90-04ab6b084797</guid><dc:creator>DeveloperZ</dc:creator><description>[quote userid="4240" url="~/f/nordic-q-a/43844/initial-spike-with-pwm-implementation/173279"]have you tried the same with other Mesh examples?&amp;nbsp;[/quote]
&lt;p&gt;Yes I did try.&amp;nbsp;&lt;/p&gt;
[quote userid="74350" url="~/f/nordic-q-a/43844/initial-spike-with-pwm-implementation/172756"]I implemented the start_PWM() function before the initialize() and start(). This doesn&amp;#39;t result in any spike.&amp;nbsp;[/quote]
&lt;p&gt;This one solved the issue because the pin is initially configured active LOW because of which there is the spike when I reboot and the initialize() function takes few ms to implement. Now, as I am initializing the PWM initially, there isn&amp;#39;t the spike.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/173279?ContentTypeID=1</link><pubDate>Wed, 27 Feb 2019 14:25:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b56c55ce-5ad3-41c3-856f-b5dac9e965cb</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Sorry, misread that. Our Mesh examples do not use Pin 11 as far as I can see. Please try the following: comment out the PWM initialization then read out the pin configuration register after the app has been initialized to determine whether the pin has its default configuration or not (input - disconnect).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;EDIT: you mentioned testing this with SDK 15.2.0, but have you tried the same with other Mesh examples?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/172793?ContentTypeID=1</link><pubDate>Mon, 25 Feb 2019 13:51:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47c034e7-16ba-4c26-88d7-4e0f473a5e75</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;Sorry, you got me wrong. They were separate applications. We were able to implement UART Tx on pin 11 in a different application and PWM on pin 11 in a different application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We never faced any error in prior cases as we never had the soft-on PWM functionality on reset.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/172789?ContentTypeID=1</link><pubDate>Mon, 25 Feb 2019 13:48:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc75e284-12ae-4cc5-ad0e-051ac369c70e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;UART Tx?&amp;nbsp;You should not have both PWM output and UART enabled on the same pin at the same time. Do you see the spike if you don&amp;#39;t initialize UART?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/172787?ContentTypeID=1</link><pubDate>Mon, 25 Feb 2019 13:43:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81519fe6-ec3e-4518-bea2-c226d0170f67</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;We are using pin 11 for &amp;quot;LIGHT_FIXTURE&amp;quot;. &amp;nbsp;There is a pin definition as SER_CONN_CHIP_RESET_PIN defined as 11 but that never affected our development till date. We were able to implement PWM and UART communication successfully on pin 11.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/172777?ContentTypeID=1</link><pubDate>Mon, 25 Feb 2019 13:32:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39ac1609-e38c-4812-a6b2-c87b090b92df</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;What pin number do you use for &amp;quot;&lt;span&gt;LIGHT_FIXTURE&amp;quot;?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/172756?ContentTypeID=1</link><pubDate>Mon, 25 Feb 2019 12:57:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2c3d7b5-7ca0-4349-ac3a-a9a20141455f</guid><dc:creator>DeveloperZ</dc:creator><description>[quote userid="4240" url="~/f/nordic-q-a/43844/initial-spike-with-pwm-implementation/172709"]Have you checked if one of the LED_x definitions in your board file is assigned to the same pin as LIGHT_FIXTURE?[/quote]
&lt;p&gt;No, there isn&amp;#39;t any definition in the board file that matches with the same pin as LIGHT_FIXTURE.&lt;/p&gt;
&lt;p&gt;Here is what we did, I implemented the start_PWM() function before the initialize() and start(). This doesn&amp;#39;t result in any spike.&amp;nbsp;&lt;/p&gt;
[quote userid="74350" url="~/f/nordic-q-a/43844/initial-spike-with-pwm-implementation/171894"]Is there any startup time for the Mesh?[/quote]
&lt;p&gt;It looks like this spike is a result of the startup/setup time for Mesh.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/172709?ContentTypeID=1</link><pubDate>Mon, 25 Feb 2019 09:38:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9374eb4b-7204-496f-b471-f4ec037e8eb9</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;So it seems like the spike is not caused by the PWM implementation then. The example do toggle LEDs to indicate various states. Have you checked if one of the LED_x definitions in your board file is assigned to the same pin as LIGHT_FIXTURE?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/171894?ContentTypeID=1</link><pubDate>Tue, 19 Feb 2019 13:15:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c500a852-e51a-494c-9ce8-1a7fe042af49</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/43844/initial-spike-with-pwm-implementation/171880"]The pin should be set low when you configure it to &amp;quot;active high&amp;quot;.[/quote]
&lt;p&gt;When I set the pin to active high, I need not change anything as the driver (active high) will have the LED connected turned OFF.&amp;nbsp;&lt;/p&gt;
[quote userid="4240" url="~/f/nordic-q-a/43844/initial-spike-with-pwm-implementation/171880"]Do you get a shorter pulse if you remove the 850 us delay?&amp;nbsp;[/quote]
&lt;p&gt;There isn&amp;#39;t any difference in the pulse&amp;nbsp;when I remove the delay or have it as the pulse is quite random. On few occasions, I won&amp;#39;t even see the pulse/spike.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there any startup time for the Mesh? Because, when we tried it with the 15.2.0 SDK, we can&amp;#39;t see that initial spike while rebooting.&lt;/p&gt;
&lt;p&gt;Thank you.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/171880?ContentTypeID=1</link><pubDate>Tue, 19 Feb 2019 12:26:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dbf3657-d45c-4203-bc41-329f909e7e4b</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The pin should be set low when you configure it to &amp;quot;active high&amp;quot;. Do you get a shorter pulse if you remove the 850 us delay?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/hmolesworth"&gt;hmolesworth&lt;/a&gt;, the app_pwm library generates the PWM output signal with the TIMER, PPI, and GPIOTE peripherals instead of using the dedicated PWM module available on the 52 series.&amp;nbsp;So this&amp;nbsp;is a different implementation.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/171739?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 20:11:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b446f1bd-ad21-4fc3-bc74-46458033fea2</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;I did try inverting the polarity of the PWM pin which is similar to what you are suggesting.&lt;br /&gt;That also has a similar spike when powering ON the driver.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/171735?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 19:57:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e05dcbc-1668-4e35-ab6f-892906a6bc6b</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;I see multiple bugs in the PWM libraries, not sure whether that would help. A fix worth trying is to use ms-bit inverted, if you haven&amp;#39;t tried already.&amp;nbsp; The startup pulse is different for Low-High PWM (value) vs. High-Low PWM (0x8000|value). I use differential PWM signals so see both simultaneously; maybe try doing this for your LED drive to see if one signal in your case looks preferable. I also control pin initialisation seperately from the library, but can get a 4uSec unwanted pulse on Low-High but not on High-Low startup.&lt;/p&gt;
&lt;p&gt;So the bugs: From the user manual&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// 6.17.5.15 PSEL.OUT[n] (n=0..3)
//  Address offset: 0x560 + (n &amp;#215; 0x4)
//  Output pin select for PWM channel n
//  Bit number 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
//          ID                                                                         C B A A A A A
// Reset 0xFFFFFFFF                  1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
//  ID RW Field Value ID Value Description
//  A RW PIN [0..31] Pin number
//  B RW PORT [0..1] Port number
//  C RW CONNECT Connection   Disconnected 1 Connected 0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;From the library for PWM nrfx_pwm.h and nrfx_pwm.c in SDK 15.2.0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief This value can be added to a pin number to inverse its polarity
 *        (set idle state = 1).
 */
#define NRFX_PWM_PIN_INVERTED    0x80

static void configure_pins(nrfx_pwm_t const * const p_instance,
                           nrfx_pwm_config_t const * p_config)
{
    uint32_t out_pins[NRF_PWM_CHANNEL_COUNT];
    uint8_t i;

    for (i = 0; i &amp;lt; NRF_PWM_CHANNEL_COUNT; ++i)
    {
        uint8_t output_pin = p_config-&amp;gt;output_pins[i];
        if (output_pin != NRFX_PWM_PIN_NOT_USED)
        {
            bool inverted = output_pin &amp;amp;  NRFX_PWM_PIN_INVERTED;
            out_pins[i]   = output_pin &amp;amp; ~NRFX_PWM_PIN_INVERTED;

            if (inverted)
            {
                nrf_gpio_pin_set(out_pins[i]);
            }
            else
            {
                nrf_gpio_pin_clear(out_pins[i]);
            }

            nrf_gpio_cfg_output(out_pins[i]);
        }
        else
        {
            out_pins[i] = NRF_PWM_PIN_NOT_CONNECTED;
        }
    }

    nrf_pwm_pins_set(p_instance-&amp;gt;p_registers, out_pins);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is no inverted bit in the manual; this affects port output initialisation and the use of Port 1.x for PWM.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Initial spike with PWM implementation</title><link>https://devzone.nordicsemi.com/thread/171726?ContentTypeID=1</link><pubDate>Mon, 18 Feb 2019 18:21:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80ee1b3d-a2a9-4143-8af7-71c856e5b27f</guid><dc:creator>DeveloperZ</dc:creator><description>&lt;p&gt;also, we logged the status of the soft on and when checking the logs we see only the first 15 values... while it had to log 300 values&lt;/p&gt;
&lt;pre&gt;, main.c,  860, ----- BLE Mesh Dimming Client Demo -----
, main.c,  787, Initializing and adding models
, main.c,  227, App OnOff Model Handle: 7
, main.c,  920, PWM max ticks: 8000
, main.c,  929, Current dimming: 0
, main.c,  929, Current dimming: 1
, main.c,  929, Current dimming: 2
, main.c,  929, Current dimming: 3
, main.c,  929, Current dimming: 4
, main.c,  929, Current dimming: 5
, main.c,  929, Current dimming: 6
, main.c,  929, Current dimming: 7
, main.c,  929, Current dimming: 8
, main.c,  929, Current dimming: 9
, main.c,  929, Current dimming: 10
, main.c,  929, Current dimming: 11
, main.c,  929, Current dimming: 12
, main.c,  929, Current dimming: 13
, main.c,  929, Current dimming: 14
Current dimming: 15&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>