Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIOTE Interrupt freezing microcontroller after code was ported over from NRF52840DK to Dongle

I am trying to port some code from the nrf52840dk (PCA10056) to the dongle (PCA10059) and everything seems to work fine until an interrupt is triggered. All serial output stops but a hard reset from the watchdog doesn't get triggered. Any help is appreciated!

I want to know why the following can run on the DK but not the Dongle and hopefully how to solve this issue. I simplified the code for debugging to init 2 interrupt pins which callback a printf/LED  something to show me its acknowledged. My code is the following;

#include "contiki.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>

#include "nrfx_gpiote.h"
#include "app_error.h"

#define INT_PIR_L				NRF_GPIO_PIN_MAP(0,20)
#define INT_PIR_R				NRF_GPIO_PIN_MAP(0,17)

PROCESS(env_test_process, "ENV_TEST");
AUTOSTART_PROCESSES(&env_test_process);
/*---------------------------------------------------------------------------*//*!
 * @brief          	Event Handler for when the right PIR sensor is triggered
 *
 * @param	pin		pin number the event was triggered
 * @param	action	the type of value change that occurred (e.g. rising edge)
 *
 */
static void pir_right_int_callback(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
	printf("[PIR]: RIGHT callback triggered \n");
}

/*!
 * @brief          	Event Handler for when the left PIR sensor is triggered
 *
 * @param	pin		pin number the event was triggered
 * @param	action	the type of value change that occurred (e.g. rising edge)
 *
 */
static void pir_left_int_callback(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
	printf("[PIR]: LEFT callback triggered \n");
}

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(env_test_process, ev, data)
{

  PROCESS_BEGIN();

  nrfx_err_t err_code;
  /* Set up Interrupt */
  nrfx_gpiote_in_config_t gpio_config = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
  gpio_config.pull = NRF_GPIO_PIN_PULLDOWN;

  err_code = nrfx_gpiote_in_init(INT_PIR_R, &gpio_config, pir_right_int_callback);
  APP_ERROR_CHECK(err_code);
  err_code = nrfx_gpiote_in_init(INT_PIR_L, &gpio_config, pir_left_int_callback);
  APP_ERROR_CHECK(err_code);

  nrfx_gpiote_in_event_enable(INT_PIR_R, true);
  nrfx_gpiote_in_event_enable(INT_PIR_L, true);

  while(1)
  {

  }

  PROCESS_END();
}

BOARD: NRF52840 Dongle (PCA10059)

OS: Contiki-NG

SDK version: 17.0.2

EDIT: I have tried replacing printf with an LED toggle but nothing is different.

  • Hi,

    How do you program the pca10059? Are you programming it through SWD interface or USB bootloader? If you are programming through the USB bootloader the application need to start from address 0x1000 due to the placement of the mbr.

    https://devzone.nordicsemi.com/nordic/short-range-guides/b/getting-started/posts/nrf52840-dongle-programming-tutorial 

    Kenneth

  • Hi Kenneth,

    I am using nrfutil with the USB bootloader to program the device. I checked the memory layout on NRF connect and can confirm the application starts from address 0x1000.

    NOTE: Anything that isn't a HW interrupt works on the device, the I2C communication, timers, etc. Its only when the HW interrupt triggers everything stops.

    nrfutil pkg generate --hw-version 52 --sd-req 0x00 --debug-mode --application build/nrf52840/dongle/env-test.hex build/nrf52840/dongle/nrf52840_dfu_image.zip
    
    |===============================================================|
    |##      ##    ###    ########  ##    ## #### ##    ##  ######  |
    |##  ##  ##   ## ##   ##     ## ###   ##  ##  ###   ## ##    ## |
    |##  ##  ##  ##   ##  ##     ## ####  ##  ##  ####  ## ##       |
    |##  ##  ## ##     ## ########  ## ## ##  ##  ## ## ## ##   ####|
    |##  ##  ## ######### ##   ##   ##  ####  ##  ##  #### ##    ## |
    |##  ##  ## ##     ## ##    ##  ##   ###  ##  ##   ### ##    ## |
    | ###  ###  ##     ## ##     ## ##    ## #### ##    ##  ######  |
    |===============================================================|
    |You are generating a package with the debug bit enabled in the |
    |init packet. This is only compatible with a debug bootloader   |
    |and is not suitable for production.                            |
    |===============================================================|
    
    
    |===============================================================|
    |##      ##    ###    ########  ##    ## #### ##    ##  ######  |
    |##  ##  ##   ## ##   ##     ## ###   ##  ##  ###   ## ##    ## |
    |##  ##  ##  ##   ##  ##     ## ####  ##  ##  ####  ## ##       |
    |##  ##  ## ##     ## ########  ## ## ##  ##  ## ## ## ##   ####|
    |##  ##  ## ######### ##   ##   ##  ####  ##  ##  #### ##    ## |
    |##  ##  ## ##     ## ##    ##  ##   ###  ##  ##   ### ##    ## |
    | ###  ###  ##     ## ##     ## ##    ## #### ##    ##  ######  |
    |===============================================================|
    |You are not providing a signature key, which means the DFU     |
    |files will not be signed, and are vulnerable to tampering.     |
    |This is only compatible with a signature-less bootloader and is|
    |not suitable for production environments.                      |
    |===============================================================|
    
    Zip created at build/nrf52840/dongle/nrf52840_dfu_image.zip
    nrfutil dfu usb-serial -p /dev/ttyACM0 -pkg build/nrf52840/dongle/nrf52840_dfu_image.zip
      [####################################]  100%          
    Device programmed.
    rm build/nrf52840/dongle/env-test.i16hex env-test.o
    

  • I think it's the OS that is doing something here, e.g. trying to access the bootloader area at the end of flash, this will cause a hardfault which could be inline with your problems.

    Kenneth

Related