We are using nRF52840DK development kit with nRF-Connect SDK to build a pre-production version of our product.
Thanks for the support in advance!
Samuel kapa
Hi Samuel,
Not sure what exactly you want to use the GPIO configuration for.
This tutorial https://devzone.nordicsemi.com/nordic/nrf-connect-sdk-guides/b/getting-started/posts/nrf-connect-sdk-tutorial---part-2-ncs-v1-4-0 shows how to config GPIO for PWM on nRF9160DK and nRF5340 PDK, but the same concept can apply to nRF52840DK. You also could search for similar use cases on Devzone.
If you want to use GPIOs independently from any peripheral, you can also use the nrfx GPIO HAL functions directly in the code without setting .overlay or .config as
#include <nrfx/hal/nrf_gpio.h> #define OUTPUT_PIN 16 void main(void) { nrf_gpio_cfg_output(OUTPUT_PIN); nrf_gpio_pin_clear(OUTPUT_PIN); }
-Amanda H.
in #define OUTPUT_PIN 16.
what's 16 means
hi Amanda H,
thanks for reply.
in #define OUTPUT_PIN 16.
what is mean by 16.
if its pin then what is port.
thanks,
samuel kapa
Hi Samuel,
It is P0.16. You can also use NRF_GPIO_PIN_MAP(port, pin) with the definition if you want to use a pin on port 1.
-Amanda H.
hi Amanda H,
here is the sample code i am writing for gpio.
#include <zephyr.h>
#include <device.h>
#include <sys/util.h>
#include <inttypes.h>
#include <devicetree.h>
#include <sys/printk.h>
#include <drivers/pwm.h>
#include <drivers/gpio.h>
#include <nrfx/hal/nrf_gpio.h>
//#define SLEEP_TIME_MS 3000
#define OUTPUT_PIN 15
void main(void)
{
nrf_gpio_cfg_output(OUTPUT_PIN);
while (1) {
nrf_gpio_pin_set(OUTPUT_PIN);
k_sleep(K_SECONDS(3U));
nrf_gpio_pin_clear(OUTPUT_PIN);
k_sleep(K_SECONDS(3U));
}
}
with is pin number 15 or 16, 13, 14. i am getting output.
but if i change the pin number to like 1 or 2. i am not getting any out put but it's uploading to board.
thanks,
samuel kapa.