Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

When should I use BUTTON_HIGH_ACCURACY_ENABLED with the button handling library?

Using NRF5 SDK 15.0.0 with nrf52832.

I'm curious about the intended use for the BUTTON_HIGH_ACCURACY_ENABLED flag in the button module.  I have a project where the main loop is spending most of its time in blocking calls to nrf_twi_mngr_perform().  When this activity is ongoing the button presses are not detected.  After the twi mngr activity ends, the buttons begin working again.   Is the a case where I should use the BUTTON_HIGH_ACCURACY_ENABLED flag?

  • I think the issue here is that you are running the TWI in blocking mode. I would highly recommend you to execute the TWI transaction in background mode, where the application receives a callback when the transactions are completed (read more about it here). Since the transaction is running in the background, the TWI will not be blocking and you will be able to detect button presses. This solution is also uses much less power, since the CPU is not constantly running (in contrast to the case where)

    Using high accuracy with the buttons will not solve your issue, and is not recommended if you want a power optimized solution, it will make it possible to directly detect a button press through a GPIOTE event. This uses more energy than the "low accuracy" option and PORT events.

    Best regards, Simon