cbluetooth-lowenergynrf51

nrf51822 / YJ-14015 Blinky


I am trying to build a simply first blinkyon a nrf51822 china clone (YJ-14015), as part of building a redox wireless and debugging why the BLE communication does not work.

As SDK I use nrf5_SDK_11 as the keyboards custom firmware is based on it.

Now I tried a very minimal example blinky with main.c

#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"

#define LED_PIN_1 1           // LED connected to pin 1       

/* --> from nrf5_SDK_11/components/drivers_nrf/hal/nrf_gpio.h
__STATIC_INLINE void nrf_gpio_pin_set(uint32_t pin_number)
{
    NRF_GPIO->OUTSET = (1UL << pin_number);
}

__STATIC_INLINE void nrf_gpio_pin_clear(uint32_t pin_number)
{
    NRF_GPIO->OUTCLR = (1UL << pin_number);
}
*/

int main(void)
{

    // Make LED pin an output pin
    nrf_gpio_cfg_output(LED_PIN_1);
    nrf_gpio_pin_set(LED_PIN_1);

    // Toggle LEDs.
    while (true)
    {
        // Down
        NRF_GPIO->OUTCLR = (NRF_GPIO->OUT & (1UL << LED_PIN_1));
        // nrf_gpio_pin_clear(LED_PIN_1);
        nrf_delay_ms(1000);

        // Up
        NRF_GPIO->OUTSET= (NRF_GPIO->OUT | (1UL << LED_PIN_1));
        // nrf_gpio_pin_set(LED_PIN_1);
        nrf_delay_ms(1000);
    }
}

My expectation would have been that I can see the voltage flip every second from high to low to high etc on PIN 01... Unfortunately I only get a 1.55 V vs ground if I attach it to my multi meter, but the voltage just stays constant and nothing changes. Anything I did wrong with this loop?

For flashing I use a ST-LinkV2 clone + the docker containers for openocd and the toolchain of the redox wireless project, which basically uses telnet over openocd. After adjusting for the right paths, flashing seems successful and as mentioned above, PIN 01 can be set to 1.55V, so I assume there is no problem with the flashing itself.


Solution

  • In case someone else stumbles across the same difficulties:

    After quite a while, I figured out a way to fix the blinky example for the yj-14015. The key was to adjust the Makefile which I took from the nordic SDK according to the Makefile in the redox firmware.

    The relevant lines being as follows:

    #flags common to all targets
    CFLAGS  = -DNRF51
    CFLAGS += -DGAZELL_PRESENT
    CFLAGS += -DBOARD_CUSTOM
    CFLAGS += -DBSP_DEFINES_ONLY
    CFLAGS += -mcpu=cortex-m0
    CFLAGS += -mthumb -mabi=aapcs --std=gnu99
    CFLAGS += -Wall -Werror -O3 -g3
    CFLAGS += -Wno-unused-function
    CFLAGS += -Wno-unused-variable
    CFLAGS += -mfloat-abi=soft
    # keep every function in separate section. This will allow linker to dump unused functions
    CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
    CFLAGS += -fno-builtin --short-enums
    
    
    # Assembler flags
    ASMFLAGS += -x assembler-with-cpp
    ASMFLAGS += -DNRF51
    ASMFLAGS += -DGAZELL_PRESENT
    ASMFLAGS += -DBOARD_CUSTOM
    ASMFLAGS += -DBSP_DEFINES_ONLY
    

    Here would be the full Makefile.