Hello,
I just started 4 days ago. My project consists of two parts. The first module that I am working on should communicate with. a I2C sensor, go to sleep for 30 seconds and repeat. Current consumption is critical, as a 2200 mA 3.6V battery should last for > 1 year. I am replacing a PIC processor that only uses in the nA range in Deep Sleep. The processor is replaces, because in the Second part of this project, I will also need to communicate using BLE with another unit.
I based my project on the TWI Sensor example, that I understand does not use a SoftDevice (SD).
I got TWI (I2C) com up and running, and I am using nrf_drv_timer_init() timer to fire an Event every 30 seconds.
Problem is that current consumption in __WFI() is ~500 uA: Need it as low as possible (<= 10 uA). Searched for days on the forum: Nothing I have tested helps!
Program structure is roughly as follows:
You can get a copy of the whole Segger project if you need, it's no secret and is not very large, but a bit messy at this experimental stage.
main() {
// Various statements found on this forum to shut down peripherals:
NRF_UART0->ENABLE = (UART_ENABLE_ENABLE_Disabled << UART_ENABLE_ENABLE_Pos);
NRF_SAADC->ENABLE = SAADC_ENABLE_ENABLE_Disabled;
twi_init();
nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG; // Probably not necessary: Done in sdk_config.h
nrf_drv_timer_init(&TIMER_LED, &timer_cfg, timer_led_event_handler);
time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_LED, time_ms);
nrf_drv_timer_extended_compare(
&TIMER_LED, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
nrf_drv_timer_enable(&TIMER_LED);
while (true)
{
// Rapid blink of LED 1 twice to see that things are running (500 ms)
nrf_drv_twi_enable(&m_twi);
float temperature = Read_Temperature_Sensor_Temperature(writeBuffer, dataBuffer, TEMP_SENSOR_ADDR);
nrf_drv_twi_disable(&m_twi); // Does not seem to reduce power...
NRF_LOG_INFO("Temperature: " NRF_LOG_FLOAT_MARKER " C \r\n", NRF_LOG_FLOAT(temperature));
NRF_LOG_FLUSH();
#if (__FPU_USED == 1)
__set_FPSCR(__get_FPSCR() & ~(0x0000009F)); // Errata had missing underscores for this call
(void) __get_FPSCR();
NVIC_ClearPendingIRQ(FPU_IRQn);
__WFI();
NRF_LOG_INFO("\r\n************ After After __WFI(); ***************");
} // end while
} // end main()
Questions
1) Can you please help tip me how to reduce the current consumption
2) The project I based my example on does not use a Softdevice. I see that many examples on how to reduce current does not compile when I do not have a SoftDevice
a) Is there a way to include SoftDevice 132 (I will use nRF52832) in an existing project?
b) I have seen the guide on how to prepare the Board with a Softdevice, but I do not understand how that works:
If I flash a SoftDevice to the Board, won't that be overwritten when I debug my program on the board, or download a hex file?
3) Using an example as a starting point gets complicated with respect to sdk_config.h once one needs to base the project on two different projects.
Is there any tool that can Merge several sdk_config.h files? I have so far done it manually, but it takes time...
Wish
It would be nice to have a Guide that shows how to Enable / Disable every peripheral, as this seems to be a recurring question on the forum.