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

NRF51 External Clock Issue on Custom PCB

Hi 

I am developing on Adafruit LE UART Friend (https://www.adafruit.com/product/2479) platform. 
Compiler: GCC 7.2.1
IDE: NetBeans 
NRF SDK: 12.3, SoftDevice S130
Debugger used SEGGER J-Link Base

This LE UART device uses a MDBT40 module which is suppose to have a 16MHz Crystal for clock inside the module as per my understanding. 

Now my problem is when i try to run a code related to softdevise it is not working when the clock sours is crystal. On changing the settings in the config file to internal oscillator it seems to work but I would like to use the crystal instead for low power consumption. 

The Code below for clock settings are not working on MTBT40 (works in the NRF51 Dongle PCM10031) 

#define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_XTAL,            \
                                 .rc_ctiv       = 0,                                \
                                 .rc_temp_ctiv  = 0,                                \
                                 .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}

I also tried using 

    NRF_GPIO->DIRSET = (1 << 19); // Use LED or other accessible pin if you want to observe the application state
    NRF_GPIO->DIRSET = (1 << 18);
    NRF_GPIO->OUTCLR = (1 << 19); 
    NRF_GPIO->OUTCLR = (1 << 18);
    
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART    = 1;
    while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
    
    NRF_GPIO->OUTSET = (1 << 19); 
    
    NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    
    NRF_GPIO->OUTSET = (1 << 18); 

When I added this code it definitely didnt go past the 2nd while loop as the GPIO 18 never went high. I made sure I used this code before the softdevice is enabled as well. 

When i try to use the RC oscillator the code is working for MTBT40 

#define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_RC ,             \
                                 .rc_ctiv       = 0,                                \
                                 .rc_temp_ctiv  = 0,                                \
                                 .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM}

Now all this being said the Adafruit UART firmware works fine on this hardware (although I dont know if Adafruit is using the external Chrystal) and as Raytac is a reputed supplier certified by Nordic I am assuming both the hardware I used to test is fine.

Please help me find what I am doing wrong. Any help will be appreciated. 

Thank You

Kaushik Ray 

Parents Reply Children
No Data
Related