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

SPI power consumption does not go down after uninit

nRF52832 power consumption is high after the SPI peripheral is used (approximately 400uA of extra current consumption). I expect it has something to do with the high speed clock, that is turned on, but not properly turned off after an uninit. 

The following uninit functions both result in high power consumption after SPI usage:

nrf_drv_spi_uninit(&spi);

and

NRF_SPI0->ENABLE = 0;

The used code:

static void spi_write(uint8_t address, uint8_t data)
{
    //Set TX buffer
    m_tx_buf[0] = address;
    m_tx_buf[1] = data;  

    // 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();
    }
}

static void sensor_init(void)
{
    //SPI driver configuration
    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.miso_pin = SPI_ACC_MISO;
    spi_config.mosi_pin = SPI_ACC_MOSI;
    spi_config.sck_pin  = SPI_ACC_CLK;
    spi_config.ss_pin = SPI_ACC_CS;
    spi_config.mode = NRF_DRV_SPI_MODE_3;
    spi_config.frequency = NRF_DRV_SPI_FREQ_125K;
    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler, NULL));

    spi_write(0x10, 0xFF);
 
    nrf_drv_spi_uninit(&spi);
//    NRF_SPI0->ENABLE = 0;
}

Parents Reply Children
Related