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 Benjamin, 

    nRF Connect SDK is our new platform and it's the platform that we will continue develop in the future. The nRF5 SDK is our legacy SDK and we stopped development on this SDK (We still support it and still provide bug fixes). 
    nRF Connect SDK has a quite steep learning curve that could be a challenge for many, including me who works at Nordic. 

    For your need I would suggest to have a look at the device tree documentation here. And we have a guide here that could be very useful for you.

    If you simply want to add an LED to your nRF5DK you can simply add an overlay file to the board to add new LED. If you are going to make your own board, you may better create a new device tree file for your board (dts). 

    I attached here a modified version of the blinky example that I added a new 2 LEDs into the board on pin P0.11 and P0.12 . Please take a look at the .overlay file inside boards folder. 

    1258.blinky_custom.zip

Reply
  • Hi Benjamin, 

    nRF Connect SDK is our new platform and it's the platform that we will continue develop in the future. The nRF5 SDK is our legacy SDK and we stopped development on this SDK (We still support it and still provide bug fixes). 
    nRF Connect SDK has a quite steep learning curve that could be a challenge for many, including me who works at Nordic. 

    For your need I would suggest to have a look at the device tree documentation here. And we have a guide here that could be very useful for you.

    If you simply want to add an LED to your nRF5DK you can simply add an overlay file to the board to add new LED. If you are going to make your own board, you may better create a new device tree file for your board (dts). 

    I attached here a modified version of the blinky example that I added a new 2 LEDs into the board on pin P0.11 and P0.12 . Please take a look at the .overlay file inside boards folder. 

    1258.blinky_custom.zip

Children
No Data
Related