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

SPI Consumption problem

I'm testing SPIM of nRF52 on PCA10040 using S132 and SDK11.

Its base on the app_peripheral_uart example, so I already have BLE communication.

When SPI is not initiated, current consuption is arround 370 uA, but when adding SPI it goes to 800uA. no matters if its transmitting or not, and theres is no way to came back to previous consuption.

I've been working hard to find a cause, but I really dont see why this is happening. I've debugged and checked SPI is coreclty stopped after TX/RX ends. I'm already using NRF52_PAN_23 define. I've even add uninit function after TX/RX ends, but its still the same.

This is the code I made to handle SPI, based on SPI example from SDK: ( acc_handler() function is called every 3 seconds from a timer based function)

define SPI_INSTANCE  0 

static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);

static volatile uint8_t spi_xfer_done; 


void spi_event_handler(nrf_drv_spi_evt_t const * p_event)

{

    spi_xfer_done = 1;
    nrf_spim_event_clear(spi.p_registers, NRF_SPIM_EVENT_END);
    nrf_spim_event_clear(spi.p_registers, NRF_SPIM_EVENT_STARTED);
    nrf_drv_spi_uninit(&spi);
}

void init_spi(void)

{

    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG(SPI_INSTANCE);
    spi_config.mosi_pin = 25;
    spi_config.miso_pin = 24,//26;
    spi_config.sck_pin = 23,//20;
    spi_config.ss_pin = NRF_DRV_SPI_PIN_NOT_USED;//SPI_CS_PIN;
    spi_config.frequency = NRF_DRV_SPI_FREQ_500K;
    APP_ERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, spi_event_handler));
    spi_xfer_done   = 1;
}

uint8_t send_spi(uint8_t *txdata, uint8_t *rxdata, uint8_t len)

{

    if(!spi_xfer_done)
      return(1);
    
    spi_xfer_done   = 0;
    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, txdata, len, rxdata, len));

    return(0);
}

void acc_handler(void)

{

uint16_t tx, rx;

  tx = 0x55AA;

  init_spi();

  send_spi((uint8_t *)&tx, (uint8_t *)&rx, 2);

}

Is there anything wrong ? Did I miss anything ?

Thanks in advance.

Parents
  • We have seen issues with SPIM0/1 and TWIM0/1 regarding this. The relevant errata for this can be found here. We are still investigating this issue so it does not cover all use cases that will lead to increased current consumption (like using SPIM0/1). When we have more information we will update this issue.

    When you say SPIO or SPI1 you mean SPIM0 or SPIM1? We thought this issue was only with the DMA enabled SPI or TWI peripheral (SPIM/SPIS/TWIM/TWIS). It is also strange that you don't see any problem with SPIM1 as this should also cause the current increase (only SPIM2 should not cause the current increase).

Reply
  • We have seen issues with SPIM0/1 and TWIM0/1 regarding this. The relevant errata for this can be found here. We are still investigating this issue so it does not cover all use cases that will lead to increased current consumption (like using SPIM0/1). When we have more information we will update this issue.

    When you say SPIO or SPI1 you mean SPIM0 or SPIM1? We thought this issue was only with the DMA enabled SPI or TWI peripheral (SPIM/SPIS/TWIM/TWIS). It is also strange that you don't see any problem with SPIM1 as this should also cause the current increase (only SPIM2 should not cause the current increase).

Children
No Data
Related