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

nRF52840: LEDs cannot work after change the port and pin.

Hi All,

I am doing a Mesh development project with nRF52840 and a custom board.
SDK version: nrf5SDKforMeshv320
Testing Example: light_switch

I had changed the port/pin for LEDs:

Original:
#define LEDS_NUMBER 4

#define LED_1 NRF_GPIO_PIN_MAP(0,13)
#define LED_2 NRF_GPIO_PIN_MAP(0,14)
#define LED_3 NRF_GPIO_PIN_MAP(0,15)
#define LED_4 NRF_GPIO_PIN_MAP(0,16)
#define LED_START LED_1
#define LED_STOP LED_4


Custom Board:
#define LEDS_NUMBER 2

#define LED_1 NRF_GPIO_PIN_MAP(1,1)
#define LED_2 NRF_GPIO_PIN_MAP(1,2)
#define LED_START LED_1
#define LED_STOP LED_2

Although the NRF_GPIO_PIN_MAP(port, pin)  had been changed, it is able to work with nRF5_SDK_15.3.0 but does not work with MESH example (nrf5SDKforMeshv320).
Please kindly need your help to advice if there is any other modification is needed in order to use port 1 for LEDs toggle.

Parents Reply
  • Hi Andreas, sorry, I am new to this development.

    I had redefine the BSP_LED_1 with NRF_GPIO_PIN_MAP(1,1), but the LED still not working.

    Btw, I found that the registers for port 1 is different with port 0:

    And the code shown:

    void hal_leds_init(void)
    {
    for (uint32_t i = LED_START; i <= LED_STOP; ++i)
    {
    NRF_P1->PIN_CNF[i] = LED_PIN_CONFIG;
    NRF_P1->OUTSET = 1UL << i;
    }

    is it the reason of not working?

    How can i fix this?

Children
  • Hi.

    The function hal_leds_init() does not work.

    What would work is if you can instead initialize all the PINS you're using as output manually for each pin, by using the function nrf_gpio_cfg_output

    __STATIC_INLINE void nrf_gpio_cfg_output(uint32_t pin_number)
    {
        nrf_gpio_cfg(
            pin_number,
            NRF_GPIO_PIN_DIR_OUTPUT,
            NRF_GPIO_PIN_INPUT_DISCONNECT,
            NRF_GPIO_PIN_NOPULL,
            NRF_GPIO_PIN_S0S1,
            NRF_GPIO_PIN_NOSENSE);
    }

    Best regards,

    Andreas

Related