This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Odd issue where lines are intermittently not going low when calling nrf_gpio_pin_clear

Let me preface by saying I'm pretty new to working at this low of a level.  I'm running a pretty simple program that is toggling a pair of pins once every half second.  The gist of the code is below:

void togglePins( const uint32 firstPin, const uint32 secondPin )
{
    nrf_gpio_cfg_output(firstPin);
    nrf_gpio_cfg_output(secondPin);

    nrf_gpio_pin_set(firstPin);
    nrf_gpio_pin_set(secondPin);
    
    while( 1 )
    {
        nrf_delay_ms(500);
        nrf_gpio_pin_toggle(firstPin);
        nrf_gpio_pin_toggle(secondPin);
    }
} // end togglePins()

This is pretty trivial code and works (sometimes).  The problem I'm having is that if I flash the SoftDevice and then my code the lines never seem to go low when connected to IAR through a SEGGER JLink.  I've tested this with both a logic analyzer and an oscilloscope and the lines just don't go down.  If I remove the debugger and reset the device the LED's toggle as expected.  After a while of being connected to IAR it will eventually work until I reset the SoftDevice again.  This definitely seems like something I'm not setting up correctly, but I've tried a ton of things and can't for the life of me figure this out.


If it makes a difference the two lines have external pullups on them and are connected to an LED driver.

Related