This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Basic GPIO on NRF52840 Development Kit

Hi, 

I'm trying to wrap my head around doing some basic GPIO reading, writing etc. and hopefully some interrupts. Apologies if these are basic questions - I've only really had experience within the Arduino framework before this.

I've got a NRF52840 Development Kit and I'm using NRF Connect for VSCode with NRF Connect v1.9.1

I've gone through the blinky and button examples, and I can get them working, and change them to address different leds/buttons. However, I'm not sure how to generalise this to other pins.

I've read a whole load of forum posts and I'm confused as to the difference between all the seemingly different GPIO libraries: what's the distinction between the libraries "drivers/gpio.h", "nrf_gpio.h", purely "gpio.h", GPIO HAL, GPIOTE, GPIO, "device.h"? Would I need to adjust the CMakeLists.txt to use these?

Are there multiple libraries for controlling GPIO things?

I've found various GPIO headers under both NRFX  (https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfx/drivers/gpio/hal.html#c.NRF_GPIO_PIN_MAP) and Zephyr (https://docs.zephyrproject.org/latest/reference/peripherals/gpio.html?highlight=gpio_pin_configure#c.gpio_pin_configure) etc.

I've also seen that a bunch of the forum posts are a) from about 5 years ago and b) referencing NRF SDK as opposed to NRF Connect SDK. Has there been an update to the GPIO libaries since then and is there a stark difference between the libraries available in the different SDKs?

Lastly, I've got a bit confused about the Devicetree in general. As I understand it, it's a set of files that contains a description of the hardware for each board so the program can find e.g. which pin is connected to an LED. If I wanted to say use pin P0.09 to control an LED that I'd wired in externally to the board, would I need to add in a new thing in the nrf52840dk_nrf52840.dts file?

Parents
  • Hi,

    I've managed to get it compiling now - I believe the error was that I had underscores in my alias names, which seems to stop the compiler from being able to find any header files? Not sure why that is, but seemed consistent.

    I've attached the program I ended up with:

    blinky_ext_led.zip

    There are still warnings when it compiles, but I'm guessing these are all fine?:

Reply
  • Hi,

    I've managed to get it compiling now - I believe the error was that I had underscores in my alias names, which seems to stop the compiler from being able to find any header files? Not sure why that is, but seemed consistent.

    I've attached the program I ended up with:

    blinky_ext_led.zip

    There are still warnings when it compiles, but I'm guessing these are all fine?:

Children
Related