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

Using External 16MHz (help with code)

Hi all! I'm a beginner developer. I start my work with nrf51822, download examples e.t.c Now I try to download my code in real PCB with external 16MHz crystal. Code worked on a kit but doesnot work on a real PCB. I think this is due to incorrect CLK. If I get datasheet right, NRF have 2 CLK generator LF and HF, In my situation, HF it is external generator 16MHz and LF generator it is should be Internal RC oscillator or a synthesized 32.768 kHz clock What should I change in the code?

code in nrf_drv_config.h file:

enter code here 
#define CLOCK_CONFIG_XTAL_FREQ          NRF_CLOCK_XTALFREQ_16MHz    
#define CLOCK_CONFIG_LF_SRC             NRF_CLOCK_LF_SRC_RC
#define CLOCK_CONFIG_LF_RC_CAL_INTERVAL RC_2000MS_CALIBRATION_INTERVAL
#define CLOCK_CONFIG_IRQ_PRIORITY       APP_IRQ_PRIORITY_LOW

And what should add in main.c for activate external clock?

Thank you for your responses!)

Parents
  • FormerMember
    0 FormerMember

    No code is needed for activating the external 16 MHz crystal. When you need the crystal, it should be sufficient to just start it.

    Could you double check that the crystal on your board is mounted correctly, i.e. not shifted by 90 degrees for example?

    Which 16 MHz crystal do you use? And what is the value of the decoupling capacitors for the crystal?

    Update 28.03.2017: The attached example shows how to easily check that the HFCLK can be started. The example is made from SDK 12.2, and should be placed in the following folder: ..\nRF5_SDK_12.2.0_f012efa\examples\peripheral : clock_122023_devzone_clock_start.zip

    The code for checking that the HFCLK is starting is the following:

    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    
    while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
    {
    }
    
  • Cristal is HC-49SM 16MHz capacitors: 33pF And parallel with Cristal I connect resistor 1M

Reply Children
No Data
Related