Hi. The main loop of my app is mostly doing SPI communication to a GPS receiver. I'd like it to do that every second or so and spend the rest of the time in system on but waiting for an event. I want nrf_pwr_mgmt_run() to block for about a second on each iteration of the main loop, so I create a repeated timer with 1 Hz frequency and a no-op handler. Instead I'm finding it returns very quickly every time - about every 1 ms.
Here's a fairly minimal test for my GPS receiver driver that reproduces the issue.
The implementation of gps_run() is a bit long but here's a cut down version of it.
Although there are SPI comms happening here, I can run this on the PCA10040 DK board (that has no GPS receiver, obvs) and it will still run OK, it just doesn't get anything back on the SPI. The same timing issue happens on my own custom board.
How can I get a better idea of what event it was that caused nrf_pwr_mgmt_run() to return?
[Edit]
I added some code right before the loop to figure out which peripherals are enabled. Here's what it showed.
Are there any non-zero values here that are unexpected for this test code above?
Here's the code for the logging, just using the INTENSET field on each peripheral (not all of them have an INTEN field):
[Edit 2]
I turned the SAADC off. It helps, but isn't sufficient. I now have my main loop iterating once every 5ms or so, up from once every 1ms. I don't understand how or why.
[Edit 3]
It's the SPI that's causing the events. Here's some updated logging:
This shows the value of the ENABLE field for each peripheral that has one, or the INTENSET for those that don't. I tried not enabling my GPIOTE peripheral but it made no difference. So I tried not enabling the SPI master. The main loop slowed down to one iteration per second.
What is the SPI doing every ms? This is testing on the DK, where there's nothing on the other end of the SPI pins but thin air. It behaves the same way on my custom board, which does have a GPS receiver there.