The led is not blinking or turning on in nrf52840 dk board

Hi I am trying to do the led blinking in nrf52840 but the led is not even turning on i have given the code below can any body help me out.

nrf_gpio_cfg_output(14);

nrf_gpio_cfg_output(15);

nrf_gpio_cfg_output(16);
nrf_gpio_cfg_output(13);
while (true)
{

nrf_gpio_pin_clear(13);
nrf_gpio_pin_set(14);
nrf_gpio_pin_set(15);
nrf_gpio_pin_set(16);
printf("Ae\r\n");
nrf_delay_ms(100);

}

Parents
  • Hello,

    The LEDs on the nRF52840 DK are active low, meaning that you have to set it to a logical zero to illuminate the LED. In your code, you are continuously setting pin 14, 15, and 16 in your while look, so there is no difference when running this in a loop. Are you not seeing your LED 1 illuminated? Is your program running at all?
    To toggle a LED I would recommend that you take a look at the Blinky Example from the SDK. Please try this example, and verify that it functions as expected.

    As an additional comment you should use the BSP_LED definitions, or create a similar NRF_GPIO_MAP define for your LEDs, so that you avoid using magic numbers in your code. This drastically increases readability and maintainability of your code.

    Best regards,
    Karl

Reply
  • Hello,

    The LEDs on the nRF52840 DK are active low, meaning that you have to set it to a logical zero to illuminate the LED. In your code, you are continuously setting pin 14, 15, and 16 in your while look, so there is no difference when running this in a loop. Are you not seeing your LED 1 illuminated? Is your program running at all?
    To toggle a LED I would recommend that you take a look at the Blinky Example from the SDK. Please try this example, and verify that it functions as expected.

    As an additional comment you should use the BSP_LED definitions, or create a similar NRF_GPIO_MAP define for your LEDs, so that you avoid using magic numbers in your code. This drastically increases readability and maintainability of your code.

    Best regards,
    Karl

Children
No Data
Related