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

SWO (pin 18) always high in secure bootloader

We have vibrator connected to gpio pin 18 on the nRF52832. Controlling it works fine in the application but as soon we enter DFU the vibrator starts and it doesn't stop until DFU is finished and we reboot into the application.

I noticed that pin 18 can also be used for SWO but as long as ENABLE_SWO is not defined, I assume that the pin should work as a gpio.

#define VIB_PIN 18
#define LED_PIN 24

int main(void)
{
    uint32_t ret_val;

    nrf_gpio_cfg_output(LED_PIN);
    nrf_gpio_cfg_output(VIB_PIN);
    nrf_gpio_pin_clear(LED_PIN);
    nrf_gpio_pin_clear(VIB_PIN);
    
     // Protect MBR and bootloader code from being overwritten.
    ret_val = nrf_bootloader_flash_protect(0, MBR_SIZE, false);
    APP_ERROR_CHECK(ret_val);
    ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE, false);
    APP_ERROR_CHECK(ret_val);

    (void) NRF_LOG_INIT(nrf_bootloader_dfu_timer_counter_get);
    NRF_LOG_DEFAULT_BACKENDS_INIT();

    NRF_LOG_INFO("Inside main");

    ret_val = nrf_bootloader_init(dfu_observer);
    APP_ERROR_CHECK(ret_val);

    // Either there was no DFU functionality enabled in this project or the DFU module detected
    // no ongoing DFU operation and found a valid main application.
    // Boot the main application.
    nrf_bootloader_app_start();

    // Should never be reached.
    NRF_LOG_INFO("After main");
}

Related