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

GPIOTE Interrupt event does not trigger on Pin P0.09 when TWI is setup on Pin P0.08 (SCL) and P0.07 (SDA). However triggers when interrupt Pin is changed to P0.13? SDK16.0

Currently I am using a PCA10040 to do some prototyping for a custom board. I intended to use the nrf52832 to interface with a HDC2010 (TI) temperature and humidity IC over TWI. The SCL is connected to pin P0.08 and SDA is connected to pin P0.07 and I can successfully read and write to the registers of the HDC chip over TWI. However, when the HDC is configured to trigger (active low) an interrupt when temperature exceeds a certain threshold; for testing purposes say 27degC, the trigger event is not called. I can see over RTT and my voltmeter that the pin is driven low, but the nrf does not act on that event. I have attached snippets of the code below. The confusing part is, when I change to pin to P0.13 (and nothing else), it works as expected. So my question is whether I have missed something with the inter-functionality of the nrf that causes this issue, or my code is missing something.

I should clarify that the modifications are made to PCA10040 as described here NFC rework to access Pin P0.09. My problem is more so, the custom board (does not use nfc features) already has the interrupt routed to P0.09, so I presume either a software modification is missed to use P0.09?

Code Details:
This is just a snippet of the code in my test environment. With this I was attempting to complete the configuration and functionality of HDC IC before integrating into the softdevice project.

configure_gpiote(void) - configures the GPIOTE interrupt as a sense High to Low using the nrfx drivers

configure_twi(void) - configures the twi interface using the nrfx drviers

interrupt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) - GPIOTE event callback

#include "nrf.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "nrf_delay.h"
#include "nrf_pwr_mgmt.h"
#include "nrfx_twi.h"
#include "app_error.h"


// GPIO and GPIOTE Inclusion details
#include "nrf_gpiote.h"
#include "nrf_gpio.h"
#include "nrf_drv_gpiote.h"
#include "nrfx_gpiote.h"

// Timer Inclusions
#include "app_timer.h"
#include "nrfx_timer.h"
#include "nrf_drv_timer.h"

#define GPIO_INPUT_PIN_HDC_DRDY_INT   (nrfx_gpiote_pin_t)9   /**< Pin number for HDC DRDY interrupt. */

// Pin Definitions
#define TWI_SCL_M           8
#define TWI_SDA_M           7
#define TWI_INSTANCE_ID     0

// TWI Slave Device Address
#define HDC2010_ADDR (uint8_t)0x40U

// HDC2010 Register address
#define HDC2010_REG_TEMP_LOW              0x00U
#define HDC2010_REG_TEMP_HIGH             0x01U
#define HDC2010_REG_HUM_LOW               0x02U
#define HDC2010_REG_HUM_HIGH              0x03U
#define HDC2010_REG_DRDY_INT              0x04U
#define HDC2010_REG_DRDY_INT_CONF         0x07U
#define HDC2010_REG_TEMP_THRESH_LOW       0x0AU // Temp Thresh low address
#define HDC2010_REG_TEMP_THRESH_HI        0x0BU // Temp Thresh high address
#define HDC2010_REG_HDC2010_CONFIG_FIELDS 0x0EU // Config field discriptions
#define HDC2010_REG_CONF                  0x0FU // measurement configuration

#define HDC2010_CONFIG_FIELDS             0x75U // Config field discriptions 01110101
#define HDC2010_DRDY_INT_CONF             0xE0U
#define HDC2010_TEMP_THRESH_LOW           0x02U // Temp Thresh low = -39
#define HDC2010_TEMP_THRESH_HI            0xC2U // Temp Thresh high = 85 degrees celcius
#define HDC2010_TEMP_20C                  0x5DU // 20 degrees celcius
#define HDC2010_TEMP_27C                  0x65U // 27 degrees celcius

/* Mode for HDC2010. */
#define MEAS_TRIG 1U

// TWI Instance Variable
static const nrfx_twi_t m_twi_master = NRFX_TWI_INSTANCE(TWI_INSTANCE_ID);

...

void interrupt_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
  int_status = true;
}

static void configure_gpiote(void)
{
  ret_code_t err_code;

  err_code = nrfx_gpiote_init();
  APP_ERROR_CHECK(err_code);

  // Configure external interrupt
  nrfx_gpiote_in_config_t config_in = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
  config_in.pull = NRF_GPIO_PIN_PULLUP;
  err_code = nrfx_gpiote_in_init(GPIO_INPUT_PIN_HDC_DRDY_INT, &config_in, interrupt_handler);
  APP_ERROR_CHECK(err_code);

  nrfx_gpiote_in_event_enable(GPIO_INPUT_PIN_HDC_DRDY_INT, true);

  NRF_LOG_INFO("All output gpios enabled \r")
  NRF_LOG_FLUSH();

}

...

static void configure_twi(void)
{
  ret_code_t ret;
  const nrfx_twi_config_t twi_config = 
  {
    .scl                = TWI_SCL_M,
    .sda                = TWI_SDA_M,
    .frequency          = NRF_TWI_FREQ_100K,
    .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
    .hold_bus_uninit     = false
  
  };

  ret = nrfx_twi_init(&m_twi_master, &twi_config, twi_event_handler, NULL);

  if (NRF_SUCCESS == ret)
  {
    nrfx_twi_enable(&m_twi_master);
  }

  APP_ERROR_CHECK(ret);

  while (nrfx_twi_is_busy(&m_twi_master));
  m_xfer_done = false;

  // Initializing HDC Params
  /* Setting Low Thershold Temp = -39 */
  uint8_t reg[2] = {HDC2010_REG_TEMP_THRESH_LOW, HDC2010_TEMP_THRESH_LOW};
  ret = nrfx_twi_tx(&m_twi_master, HDC2010_ADDR, reg, sizeof(reg), false);
  while (m_xfer_done == false);
  
  m_xfer_done = false;
  /* Setting High Thershold Temp = 20 */
  reg[0] = HDC2010_REG_TEMP_THRESH_HI;
  reg[1] = HDC2010_TEMP_27C;
  ret = nrfx_twi_tx(&m_twi_master, HDC2010_ADDR, reg, sizeof(reg), false);
  while (m_xfer_done == false);
   
  m_xfer_done = false;
  /* Setting Config Felds Config */
  reg[0] = HDC2010_REG_HDC2010_CONFIG_FIELDS;
  reg[1] = HDC2010_CONFIG_FIELDS;
  ret = nrfx_twi_tx(&m_twi_master, HDC2010_ADDR, reg, sizeof(reg), false);
   while (m_xfer_done == false);
  
  m_xfer_done = false;
  /* Setting Interrupt Config */
  reg[0] = HDC2010_REG_DRDY_INT_CONF;
  reg[1] = HDC2010_DRDY_INT_CONF;
  ret = nrfx_twi_tx(&m_twi_master, HDC2010_ADDR, reg, sizeof(reg), false);
   while (m_xfer_done == false);

  reg[0] = HDC2010_REG_CONF;
  reg[1] = 0xA0; //10100000
  ret = nrfx_twi_tx(&m_twi_master, HDC2010_ADDR, reg, sizeof(reg), false);
   while (m_xfer_done == false);

  NRF_LOG_INFO("HDC2010 configured \r")
  NRF_LOG_FLUSH();
    
}

...

/**@brief Function for application main entry.
 */
int main(void)
{
  uint16_t int_counter = 1;
  configure_log();
  lfclk_request();
  timers_init();
  NRF_LOG_INFO("TEST --- Development environment --- begin\r")
  NRF_LOG_FLUSH();
  configure_gpiote();
  configure_twi();
  trigger_measurement();
  read_sensor_data();

  ret_code_t err_code;
  err_code = app_timer_start(m_app_timer_id, APP_TIMER_TICKS(1000), NULL);
  APP_ERROR_CHECK(err_code); 
  
  while(true)
  {
    if(int_status)
    {
      NRF_LOG_INFO("External Interrupt Triggered: %d !! \r", int_counter)
      int_status = false;
      int_counter = int_counter + 1;
      NRF_LOG_FLUSH();
      app_timer_stop(m_app_timer_id);
      nrf_delay_ms(500);
      app_timer_start(m_app_timer_id);
    }

  }
  
}

Parents Reply Children
No Data
Related