NUS shut down & restart

I've built a project based on the peripheral_uart appliction. This is working well, but I need to now sort out the lowpower mode. My product is battery powere & I need to turn everything off when the power button is pressed.

Is there a deffined way to do this?

I will also need to restart it when the power button is pressed again.

Parents
  • Hi Priyanka,

    I've now finally got back on to this. I'm using the dk_buttons library

    gpio_pin_set_dt(&j3pins[2], 1); //### test probe: set high when enter poweroff
    sys_poweroff();
    gpio_pin_set_dt(&j3pins[2], 0); //### test probe: set low when exit poweroff
    Monitoring my test probe pin it goes high as expected when entering sys_poweroff() & when I press my button my test probe goes low as expected, but it doesn't carry on running from where it left off. I then put a break point at the system start which it hit. It seams to reset my code & run from the begining?
    Is that correct?
    Also I noticed your comment in the other ticket saying that dk_buttons_and_leds.c library you see a higher IDLE current.
    does "sense-edge-mask = <0x01800000>; /* 1<<24 | 1 <<23 */" solve this issue? If so, are this bits related for their GPIO pins (23 & 24)?
  • Hi John,

    John Galvin said:
    It seams to reset my code & run from the begining?
    Is that correct?

    Yes you can see here https://docs.nordicsemi.com/bundle/ps_nrf5340/page/chapters/reset/doc/reset.html  that the device resets when waking up from System OFF, so then it starts from the main().

    John Galvin said:
    does "sense-edge-mask = <0x01800000>; /* 1<<24 | 1 <<23 */" solve this issue?

    The higher idle current come from using GPIOTE IN channels for GPIO interrupts. Switching those pins to use the GPIO SENSE/PORT event path usually fixes it. That’s exactly what the sense-edge-mask devicetree property does.

    -Priyanka

Reply Children
  • I was able to use the restart option by chaning my software to allow a restart to test the buttons. How I get excellent power off current (~300nA)

    One note. If I press the wrong button to wake it up, then realse this & press the correct button, it doesn't wake. I'm guessing I needed to clear the IRQ before going back to sleep after the wrong button press. Howver, I get round this by waiting for the wrong button to be released before going back to sleep. This fixed my problem.

    Can you see any reason why this may not be a suitable solution?

  • Hi John,

    Apologies for the delayed response.

    John Galvin said:
    get round this by waiting for the wrong button to be released before going back to sleep. This fixed my problem.

    This sounds like a good solution and sounds fine.

    -Priyanka

Related