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

Increase current consumption with TWI after calling nrf_twi_uinit

Hi,

I am working with a custom board with a third party NRF52832 module. On my board I have a DS3231M real time clock IC communicating with the NRF52832 via I2C/TWI and 2 push buttons that uses GPIOTE. My application requires very low power consumption and I am struggling with keeping the current consumption low while communicating with the DS3231M via TWI. My program is modified from the ble_app_uart example (PCA10040 S132) and I am using SES for editing.

The RTC module has 2 power source (let me call it RTC_VCC and VBat). To reduce power consumption, I have connected RTC_VCC to a GPIO pin (P0.03) and will only set P0.03 to high whenever I need to communicate with the RTC module via TWI. P0.03 will be set to 0 whenever TWI communication is completed. VBat is connected to VCC (3.3V) on my board (same supply as the NRF52832). This setup is used so that the RTC module can use minimum current.

Here is description of the problem:

In my main program, I first declare the TWI instance

/* TWI instance ID. */
#define TWI_INSTANCE_ID     0

/* TWI instance. */
static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID);

My TWI is initialized as follows:

/**
 * @brief TWI initialization.
 */
void twi_init (void)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_config = {
       .scl                = NRF_GPIO_PIN_MAP(0,29),
       .sda                = NRF_GPIO_PIN_MAP(0,30),
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

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

    nrf_drv_twi_enable(&m_twi);
}

In my main program, 1 second after initializing TWI, I enable the DS3231M by setting P0.03 to HIGH to turn on the RTC. I do nothing (no TWI communication at all), use app_timer to delay for a short time, then turn off the DS3231M by clearing P0.03. I did not un-init the TWI. After that I broadcast for 3 seconds before going to sleep:

static void sleep_mode_enter(void)
{
    // Sleep
    uint32_t err_code = sd_app_evt_wait();
    APP_ERROR_CHECK(err_code);
}

With this, when the NRF52832 goes to sleep, I am getting a sleep current of about 10uA.

Next, just added 4 more lines to disable and uninit the TWI:

    nrf_drv_twi_disable(&m_twi);
    nrf_drv_twi_uninit(&m_twi);
    *(volatile uint32_t *)0x40003FFC = 0;
    *(volatile uint32_t *)0x40003FFC;
    *(volatile uint32_t *)0x40003FFC = 1; 

With TWI disable and uninit, when the NRF52832 goes to sleep, I am getting a sleep current of about 80uA. This does not make sense to me.

I also tried another scenario where I use TWI to communicate with the DS3231M (write to a register). If I do not disable and uninit TWI, I am getting a sleep current of 440uA

If I use TWI to communicate with the DS3231M (write to a register) and disable and uninit TWI, I am getting a sleep current of about 70uA.

 

Why is the sleep current at 10uA when I do not disable and uninit TWI? And why does the sleep current increase after I perform TWI communication and disable and uninit TWI? Is it not possible to perform TWI communication, disable and uninit TWI and have a sleep current of 10uA?

Parents
  • Hello.

    I managed to solve the problem. It was mostly a hardware issue with the DS3231M RTC chip. I just connect the primary supply to GND and the battery supply to VCC (3.3V) and the current reduced a lot.

    Disabling high accuracy mode for the GPIOTE also helps. Now I am able to achieve less than 10uA during sleep and wake up with GPIOTE pin interrupt.

    I am just having some issues with timing ( i need to generate delays in my program) and its causing the program to freeze. I will try to troubleshoot it first on my own before opening another thread to discuss the problem.

    Thanks!

Reply
  • Hello.

    I managed to solve the problem. It was mostly a hardware issue with the DS3231M RTC chip. I just connect the primary supply to GND and the battery supply to VCC (3.3V) and the current reduced a lot.

    Disabling high accuracy mode for the GPIOTE also helps. Now I am able to achieve less than 10uA during sleep and wake up with GPIOTE pin interrupt.

    I am just having some issues with timing ( i need to generate delays in my program) and its causing the program to freeze. I will try to troubleshoot it first on my own before opening another thread to discuss the problem.

    Thanks!

Children
No Data
Related