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

Raytac MDBT50Q-RX Dongle (nRF52840) LED problem

Hello!

I managed to flash my Raytac dongle with debugging going using the SWD on a nrf52 DK.
I am mainly working with SEGGER Embedded Studio and nRF Connect on Mac.
However, it seems any function from simple_hal simply won't work...

I created a new header file in SDK/components/boards/ which defines the only LED of the Raytac MDBT50Q-RX Dongle:

...
// LED definitions for MDBT50Q-RX #define LEDS_NUMBER 1 #define LED_1 NRF_GPIO_PIN_MAP(1,13) #define LED_START LED_1 #define LED_STOP LED_1

#define LEDS_LIST { LED_1 }
...

Sadly, my application (using the mesh SDK) just won't light up with the Raytac dongle, while working perfectly with the nRF52840 DK (PCA10056) and the nordic nRF52840 Dongle (PCA10059)

Until I included these 2 lines in my main.c:

nrf_gpio_cfg_output(LED_1);
nrf_gpio_pin_write(LED_1, value);

I could reproduce this on both the light_switch server & client.

If anyone could enlighten me.. ^^

Thank you!

PS: if this is truly impossible, could someone guide me onto how to write an async blink?
This is blocking the process quite a bit:

for(int i=0; i<10; i++) {
  nrf_gpio_pin_write(LED_1, i%2);
  nrf_delay_ms(500);
}
  • This workaround may be problematic if you want to use port 0. I would suggest to go over the project setup and compare it to a 52840 SDK project to find out why the wrong header files are being included. 

  • Hello Vidar !

    I'm fully aware of that. That was a simple workaround not a solution.
    I ended up discarding that workaround's changes and instead changing the code in simple_hal.c. Everywhere it had NRF_GPIO, I changed it to something like:

    #if LED_1<=32
    NRF_GPIO->OUT ^= m_blink_mask;
    #else
    NRF_P1->OUT ^= m_blink_mask;
    #endif

    and readjust the pin in functions like the hal_leds_init function to:

    for (uint32_t i = LED_START; i <= LED_STOP; ++i)
    {
      #if LED_1<=32
        NRF_GPIO->PIN_CNF[i] = LED_PIN_CONFIG;
        NRF_GPIO->OUTSET = 1UL << i;
      #else
        NRF_P1->PIN_CNF[i-32] = LED_PIN_CONFIG;
        NRF_P1->OUTSET = 1UL << i-32;
      #endif
    }

    It is not perfect but, I believe, more appropriate. (It would cause problems again if we had a LED on each port, the init function also seem to take for granted that the ports are not apart but one after the other...)
    and then boards.h functions like LEDS_OFF(BSP_LED_0_MASK); or LEDS_ON(BSP_LED_0_MASK); still use NRF_GPIO and won't work. Although applying the same treatment should solve this too.

    I feel like there is still something to be done to make this better, now that I'm looking at boards.h's

    #define PIN_MASK(_pin) (1u << (uint32_t)((_pin) & (~P0_PIN_NUM)))

    where (uint32_t)((_pin) & (~P0_PIN_NUM)) returns 13 for the pin 45 (1,13). Basically what I was doing with the -32. I still don't fully grasp the masks..

    I will keep looking at this when I have the time but for now this solved my problem.

    Thank you for your support!

  • As I was saying, the current simple_hal.c is incompatible with the LED pins on the PCA10059.

    #define LED1_G         NRF_GPIO_PIN_MAP(0,6)
    #define LED2_R         NRF_GPIO_PIN_MAP(0,8)
    #define LED2_G         NRF_GPIO_PIN_MAP(1,9)
    #define LED2_B         NRF_GPIO_PIN_MAP(0,12)
    #define LED_1          LED1_G
    #define LED_2 LED2_R
    #define LED_3 LED2_G
    #define LED_4 LED2_B
    #define LED_START      LED_1
    #define LED_STOP       LED_4

    More exactly, the 3rd one won't work.

  • simple_hal.c

    Is that a Nordic SDK thing?

    EDIT

    Oh - it's a Mesh SDK thing.

  • yes. nrf5SDKforMeshv310src/examples/common/src/simple_hal.c

Related