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

nrf_drv_gpiote_out_set() is my power switch

To conserve battery power, my Beacon application powers an attached sensor off GPIO pin 24. That way, when the sensor isn't needed I simply call nrf_drv_gpiote_out_clear(24); and call nrf_drv_gpiote_out_set(24); when I'm ready to use it again.

As an experiment, I wrote code to set the pin and wait in an endless loop, and then I placed a voltmeter's probes on the Beacon's GPIO 24 and ground pins. It's not showing any voltage, which seems to indicate the "set" didn't work. I can verify that no ASSERTs executed.

I have a few questions about this:

  1. Is it even possible to power a sensor on the voltage that comes from a GPIO pin?
  2. Am I measuring the GPIO pin's state correctly by using the voltmeter as described?
  3. Is there anything else I need to know about powering down sensors on the Beacon board?

Thank you!

  • Hi,

    1. Yes, you can draw up to 0.5 mA in standard drive and 5 mA in high drive on the GPIO pins.
    2. Yes, it sounds correct.
    3. Make sure to gracefully shut down the communication with the sensor before shutting it off, and in most cases you should be fine.

    As to why setting the pin does not work, check to see if it is already in use by other peripherals, and check if the gpiote driver and the pin is correctly initialised. As you are using the CPU to control the GPIOs, things must be done slightly differently from the GPIOTE peripheral example (which uses PPI for toggling the pin.)

    Regards, Terje

Related