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

nrf_gpio_pin_set() causes reset

I have a modem connected to some pins on an nRF51822 on a custom board. Two pins on the modem are active low. One is a reset pin, the other a VCC control. I want these pins on the Nordic configured as output but I want them high immediately, because at this point I'm not powering up the modem, just init()ing my pins. I don't see any way to set an initial state of the pin at the same instant as configuring it as output (despite the comment in nrf_gpio.h L125), so I simply set them high right after configuring them as output.

nrf_gpio_cfg_output(PIN_SF_RESET);
nrf_gpio_pin_set(PIN_SF_RESET);

nrf_gpio_cfg_output(PIN_SF_VCC_ON);
nrf_gpio_pin_set(PIN_SF_VCC_ON); // This causes a reset!

That last call to nrf_gpio_pin_set() will reset the micro about 80% of the time. This is with the SD enabled and I've just started advertising, in case that makes any difference. I'm on SDK 8.0.0. I've tried this on two identical prototype boards and the same thing happens, so it's not a hardware fault on one board.

What might cause this and how can I avoid it?

Parents
  • Since that macro does nothing but set a bit in the output register I can see no way that could actually be the cause of a reset, unless PIN_SF_VCC_ON is 26 or 27.

    I think you must be failing somewhere else. Start in the hardfault handler, are you going in there, where did you come from? If you reset, what's the reset reason (read it out of the register).

    (note: you can set a pin high as soon as you make it an output by setting it high first then making it an output, although that has nothing at all to do with your issue).

  • You're right, it had nothing to do with the GPIO stuff. It was an assert in the soft device cause by starting to advertise and then doing stuff right after that.

Reply Children
No Data
Related