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

is spi in nrf52832 consume large current ?

i measured the current of nrf52 dk board with the spi example (examples\peripheral\spi\pca10040). the result shows that it consumed about 6 mA !!! i read the nrf52 datasheet, spi consumes up to 50 uA. below is the example code, int main(void) { LEDS_CONFIGURE(BSP_LED_0_MASK); LEDS_OFF(BSP_LED_0_MASK);

APP_ERROR_CHECK(NRF_LOG_INIT(NULL));

NRF_LOG_INFO("SPI example\r\n");

nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin   = SPI_SS_PIN;
spi_config.miso_pin = SPI_MISO_PIN;
spi_config.mosi_pin = SPI_MOSI_PIN;
spi_config.sck_pin  = SPI_SCK_PIN;
APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler));

while (1)
{
    // Reset rx buffer and transfer done flag
    memset(m_rx_buf, 0, m_length);
    spi_xfer_done = false;

    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, m_tx_buf, m_length, m_rx_buf, m_length));

    while (!spi_xfer_done)
    {
        __WFE();
    }

    NRF_LOG_FLUSH();

    LEDS_INVERT(BSP_LED_0_MASK);
    nrf_delay_ms(200);
}

}

how to save the power ? could anyone give link to figure it out?

  • The example in the SDK uses nrf_delay_ms() function to wait for a new transaction. This function is basically just a for loop counter, which means that the CPU draws current all the time (several milliamps).

    You could use the RTC to trigger the SPI transfer and let the CPU sleep in between.

    Below is a modification to the SDK example code (SDK 11.0.0) that will do this. Notice that I've moved the code inside the while(1) loop in main() to the RTC interrupt handler. And it calls __WFE() which puts the CPU to sleep until the RTC interrupt wakes it up.

    I've also enabled the DCDC to use this more power efficient regulator. Remove this line if you don't have DCDC components on your custom PCB. If you're using the dev-kit, this should be enabled.

    Modified example: main.c

    To get the total SPI transfer current you have to add the peripheral clock current. SPI uses the peripheral clock which in turn requires the HF clock to be running. This can either be the the internal HF clock or an external crystal. infocenter.nordicsemi.com/.../clock.html

    Also some current for the easy DMA must be taken into account (undocumented), since the SPIM peripheral writes directly to RAM using DMA.

    The HFCLK and DMA currents are only during transaction, and between the transactions you should expect to get the System ON base current pluss RTC and LF clock currents. About 2 µA in total.

Related