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

Simple GPIO Example - nRF9160 DK

Hello,

I'm having difficulty getting the GPIO set up in a way that behaves predictably on the nRF9160 DK. As far as I understand it, the nRF52840 is what controls the GPIO on the board, and the nRF9160 has to send its requests through it to interact. However, some pins on the 9160 are routed directly to things like the LEDs or switches.

My goal is very simple - I need to control pins 2, 4, 6, and 7 during execution. But when I define the pins, the results are not as expected:

struct device *gpio_dev;
gpio_dev = device_get_binding(DT_GPIO_P0_DEV_NAME);
gpio_pin_configure(gpio_dev, 2, GPIO_DIR_OUT);
gpio_pin_write(gpio_dev, 2, 1);

Unfortunately, this does not pull P0.02 high, and instead illuminates one of the LEDs. Any advice would be appreciated!

As an aside, I find that the documentation rarely provides the final answer to my problems. I'm a beginner, but I'm also someone who digs for answers for hours at a time until he solves his problems. I would love to learn about each aspect of programming this board, but I don't know where to begin. A lot of the time I depend on grepping through entire directory trees to find symbols that my IDE could not. I have no idea where to find a guide to using prj.conf, .overlay files, and so on. It doesn't seem that there is a good tutorial that can bring someone up to speed from the beginning. And yes, I have used the getting started tutorials, looked at every example, and read tons of forum posts. It's still necessary for me to make posts here, unfortunately. There should be very simple example given for every feature listed on the product page, even if they're redundant.

Related