How to get a programm running on a custom designed board? nRF52832

Hi,

i am working on a project using the nRF52832 SoC. I had to design a custom PCB for my application as shown in Scematics.

Schematic_nrf52832_prototype_1.0_2023-01-10.pdf

The issue is not the hardware though. I got a Programm running in Segger Embedded Studios which turns a LED on and off. Thats why i know that the Hardware works.

 .

I did upload the programm using a nRF52_DK as shown in the picture. This worked well.

What I am trying to do, is programming my device using Nordic SDK in VS Code. It would be enough to just upload a simple blinky sketch (to understand what is essential to run the program on the custom board) and from there i can move on, but even that doesnt work. p.s.The finished project requires GPIOs, I2C, UART and BLE.I am not able to get the code working on a custom board even if its the same code that i have programmed on the DK (it works on the DK). I've tried doing it like in this video shown https://www.youtube.com/watch?v=KSivO9Cf1TE&t=2050s but it wont work and i cant find the reason. The result I came up with is the following.

2746.boards.zip

The sample code i was using: (if button gets pressed, then the led goes on)

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/printk.h>
#include <inttypes.h>

#define SLEEP_TIME_MS   1
#define SW_NODE DT_ALIAS(sw0)

#if !DT_NODE_HAS_STATUS(SW_NODE, okay)
#error "Unsupported board: sw0 devicetree alias is not defined"
#endif
static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET_OR(SW_NODE, gpios,
                                  {0});
static struct gpio_callback button_cb_data;

static struct gpio_dt_spec led = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led0), gpios,
                             {0});

void button_pressed(const struct device *dev, struct gpio_callback *cb,
            uint32_t pins)
{
    printk("Button pressed at %" PRIu32 "\n", k_cycle_get_32());
}


void main(void)
{
    gpio_pin_configure_dt(&button, GPIO_INPUT);
    gpio_pin_interrupt_configure_dt(&button,
                          GPIO_INT_EDGE_TO_ACTIVE);

    gpio_init_callback(&button_cb_data, button_pressed, BIT(button.pin));
    gpio_add_callback(button.port, &button_cb_data);
    printk("Set up button at %s pin %d\n", button.port->name, button.pin);

    gpio_pin_configure_dt(&led, GPIO_OUTPUT);

    printk("Press the button\n");
    if (led.port) {
        while (1) {
            /* If we have an LED, match its state to the button's. */
            int val = gpio_pin_get_dt(&button);

            if (val >= 0) {
                gpio_pin_set_dt(&led, val);
            }
            k_msleep(SLEEP_TIME_MS);
        }
    }
}

What is missing or what am I doing wrong? What do i need to do, to upload this sketch with VS Code on my Custon Board? Why doesnt it work if i upload the programm with the board configuration form the nRF52832_DK? (if i put the leds and buttons on my custom board on the same pins as on the DK should it work then?)

  • Hello Daniel,

    The issue is not the hardware though. I got a Programm running in Segger Embedded Studios
    What I am trying to do, is programming my device using Nordic SDK in VS Code.

    So if I have understood you correctly, you are able to program the custom board using Segger, but you are not able to program it using VSC? In that case I don't think the board or the code is the problem. I would rather think there are some files that haven't been correctly configured in VSC (eg. an overlay file that VSC isn't seeing). 

    Why doesnt it work if i upload the programm with the board configuration form the nRF52832_DK? (if i put the leds and buttons on my custom board on the same pins as on the DK should it work then?)

    This sounds like a potential problem, but if it did work in SES then it shouldn't be an issue at the moment. If everything you need to eg. blink an LED was the same in the DK dts files and your custom boards dts files you might as well just use the dts files for the 52DK for this test. Either way, if you did indeed manage to program the custom board using SES then the board files shouldn't be the issue. 

    Have I understood you correctly this far?

    Regards,

    Elfving

Related