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

enable TWI, external interrupt and Hight frequency clock with Soft Device enabled.

Hi,

I need to minimize the power consumption.

For this reason when my device is in advertising the peripherals:

  • TWI
  • hight frequency clock
  • external interrupt on one pin.

are not enabled. In this configuration between 2 advertising the current consuption in my device is about 2 uA (@3V).

If the peripherals are enabled the current is about 400 uA. (160uA for interrupt, 220uA for TWI and 20uA for clock)

When the device is connected I need to init the above peripherals.

The problem occur when I try to init the peripherals with Soft Device enabled, the processor go in HardFault handler.

I understand that I need to use the API but I can't found documentation on this argoment.

Only for the clock I have found: sd_clock_hfclk_is_running and sd_clock_hfclk_release

Can you suggest me the correct API to call to init and deinit TWI and external interrupt ?

Now I use for the interrupt:

   err_code = nrf_drv_gpiote_init();
   APP_ERROR_CHECK(err_code);
   nrf_drv_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
   in_config.pull = GPIO_PIN_CNF_PULL_Disabled;
   in_config.sense = GPIOTE_CONFIG_POLARITY_HiToLo;
   err_code = nrf_drv_gpiote_in_init(PIN_P0_07_INT, &in_config, in_pin_handler);
   APP_ERROR_CHECK(err_code);

and for twi:

    err_code = nrf_drv_twi_init(&m_twi, &twi_lm75b_config, twi_handler, NULL);
    APP_ERROR_CHECK(err_code);
    nrf_drv_twi_enable(&m_twi);

Thanks

Marco

Parents Reply Children
No Data
Related