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

MetaWear custom firmware

Hello, I am trying to upload my custom firmware to the MetaWear RG (nrf51822) platform but currently without luck. Steps that I have performed:

  • Connected to the device using the debug out of the nRF51DK as described here
  • Uploaded Softdevice S130
  • Uploaded custom application

Now, uploading seems to be working fine, but the application/mcu doesn't seem to start/work. I believe the problem lies in not correctly configuring the application to use the 32MHz external crystal, which the MetaWear uses.

To try to achieve that:


Step 1

it is being suggested to write the value 0xFFFFFF00 to the UICR (User Information Configuration Register) at address 0x10001008 (XTALFREQ).

# After softdevice upload and when the UICR can be written to
# Using nrfprog.exe (not tested, but should work)
nrfjprog.exe --snr <your_jlink_debugger_serial_number> --memwr 0x10001008 --val 0xFFFFFF00
# Using jlink (my method)
w4 0x10001008 0xFFFFFF00

I can verify that address 0x10001008 has been written to correctly.

Step 2

I edited the nrf_drv_config.h to use NRF_CLOCK_XTALFREQ_32MHz.

Step 3 (Edit 1)

based on this I changed the definition at the top of the system.nrf51.c file to

#define __SYSTEM_CLOCK      (32000000UL)

and I also explicitly enabled the use of the external 32MHz crystal in the application code like:

int main(void)
{
    // Set the external high frequency clock source to 32 MHz
    NRF_CLOCK->XTALFREQ = 0xFFFFFF00;

    // Start the external high frequency crystal
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;

    // Wait for the external oscillator to start up
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {}

    while (true) {
        // run application
    }
}

Using nRF51_SDK_9.0.0_2e23562

Any clues? Has anyone successfully managed to run custom code in the metawear?

Any help appreciated! Thanks!

Related