Hello,
I am using the SPIM module to communicate the NRF52832 with a sensor, every time it generates an interrupt - which is generated with a frequency of 25Hz. For the interruption I am using the GPIOTE. Between the sensor readings, when an interrupt is generated, I put the microcontroller in sleep mode with sd_app_evt_wait. The problem is that I have a much higher consumption than expected, since there are consumption peaks of around 400uA. I have already checked the pull of the MISO pin and disabled everything that was possible possible to isolate the problem.
So, I figured it would probably be related to Errata 89, but I had doubts when implementing the workarround.
#define SPI_INSTANCE 2
static const nrf_drv_spi_t hspi = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE);
static volatile bool spi_xfer_done = 0;
void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
void * p_context)
{
spi_xfer_done = true;
}
void spi_init(void)
{
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
APP_ERROR_CHECK(nrf_drv_spi_init(&hspi, &spi_config, spi_event_handler, NULL));
nrf_drv_spi_uninit(&hspi);
*(volatile uint32_t *)0x40023FFC = 0;
*(volatile uint32_t *)0x40023FFC;
*(volatile uint32_t *)0x40023FFC = 1;
nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
APP_ERROR_CHECK(nrf_drv_spi_init(&hspi, &spi_config, spi_event_handler, NULL));
}
void spi_read(void)
{
spi_xfer_done = false;
nrf_drv_spi_transfer(&hspi, spi.buff, 0, spi.buff, spi.size);
while (!spi_xfer_done);
}
void spi_write(void)
{
spi_xfer_done = false;
nrf_drv_spi_transfer(&hspi, spi.buff, spi.size, spi.buff, 0);
while (!spi_xfer_done);
}
void spi_write_read(uint8_t *pTxData, uint8_t *pRxData, uint16_t Size)
{
spi_xfer_done = false;
nrf_drv_spi_transfer(&hspi, pTxData, Size, pRxData, Size);
while (!spi_xfer_done);
}
Is initializing SPI this way enough for the workarround to work?
Beside that, I tried to use just the SPI, without the DMA. But it also didn't reduce the consume. Is it expected?


