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

SDK 1.6.1 How Enable Internal 32 KHz oscillator

Hi,

I have a board whitout 32 KHz crystal, how enable the internal oscillator?

Thanks in avance.

Fausto

Parents
  • Hi,

    For enable Internal Osc

    in prj.conf

    CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
    or
    for Synthesized from HFCLK
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y
  • Hi,

    i set only this flags or have to make changes in the application code?

    Thanks for your support.

    Fausto

  • No changes in main application. Just adding the line to the config file and open the project fresh it will works

  • HI Sunil,

    I added the CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH = y flag in the blinky example, and the firmware works.

    I have also added in the blinky example the possibility to update via FOTA.

    On the NRFDK52 board the firmware is working, the LED flashes and the FOTA is performed.

    But if I load the same firmware on the custom board, which does not have 32 KHz crystal, the program does not run.

    Doing some tests I saw that if I change the flag from CONFIG_BOOTLOADER_MCUBOOT = y to CONFIG_BOOTLOADER_MCUBOOT = n, the firmware starts, I see the bluetooth device, on the nRF Connect application, I can connect to the board, I see the DFU button but it does not upgrade. I attach the source code and the prj.conf file

    Thanks for your suggestions to solve this other problem.5460.prj.conf

    /*
     * Copyright (c) 2016 Intel Corporation
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr.h>
    #include <stats/stats.h>
    #include <device.h>
    #include <devicetree.h>
    #include <drivers/gpio.h>
    #include <bluetooth/bluetooth.h>
    #include <bluetooth/hci.h>
    #include <bluetooth/gap.h>
    #include "common.h"
    /* 1000 msec = 1 sec */
    #define SLEEP_TIME_MS 100
    
    /* The devicetree node identifier for the "led0" alias. */
    #define LED0_NODE DT_ALIAS(ledh)
    
    #if DT_NODE_HAS_STATUS(LED0_NODE, okay)
    #define LED0	DT_GPIO_LABEL(LED0_NODE, gpios)
    #define PIN	DT_GPIO_PIN(LED0_NODE, gpios)
    #define FLAGS	DT_GPIO_FLAGS(LED0_NODE, gpios)
    #else
    /* A build error here means your board isn't set up to blink an LED. */
    #error "Unsupported board: led0 devicetree alias is not defined"
    #define LED0	""
    #define PIN	0
    #define FLAGS	0
    #endif
    
    
    
    #ifdef CONFIG_MCUMGR_CMD_FS_MGMT
    #include <device.h>
    #include <fs/fs.h>
    #include "fs_mgmt/fs_mgmt.h"
    #include <fs/littlefs.h>
    #endif
    #ifdef CONFIG_MCUMGR_CMD_OS_MGMT
    #include "os_mgmt/os_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_IMG_MGMT
    #include "img_mgmt/img_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_STAT_MGMT
    #include "stat_mgmt/stat_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_SMP_BT
    #include "mgmt\mcumgr\smp_bt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_SHELL_MGMT
    #include "shell_mgmt/shell_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_FS_MGMT
    #include "fs_mgmt/fs_mgmt.h"
    #endif
    
    void main(void)
    {
     const struct device *dev;
     bool led_is_on = true;
     int ret;
     /*
     NRF_CLOCK-> LFCLKSRC = 0;
     NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
     NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
     NRF_CLOCK->TASKS_LFCLKSTART    = 1;
    
    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
    {
        // Do nothing.
    }
    */
    
     os_mgmt_register_group();
     img_mgmt_register_group();
     smp_bt_register();
     
     #ifdef CONFIG_MCUMGR_SMP_BT
    	start_smp_bluetooth();
     #endif
    
            dev = device_get_binding(LED0);
    	if (dev == NULL) {
    		return;
    	}
    
    	ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
    	if (ret < 0) {
    		return;
    	}
    
    	while (1) {
    		gpio_pin_set(dev, PIN, (int)led_is_on);
    		led_is_on = !led_is_on;
    		k_msleep(SLEEP_TIME_MS);
                    STATS_INC(smp_svr_stats, ticks);
    	}
    }
    

Reply
  • HI Sunil,

    I added the CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH = y flag in the blinky example, and the firmware works.

    I have also added in the blinky example the possibility to update via FOTA.

    On the NRFDK52 board the firmware is working, the LED flashes and the FOTA is performed.

    But if I load the same firmware on the custom board, which does not have 32 KHz crystal, the program does not run.

    Doing some tests I saw that if I change the flag from CONFIG_BOOTLOADER_MCUBOOT = y to CONFIG_BOOTLOADER_MCUBOOT = n, the firmware starts, I see the bluetooth device, on the nRF Connect application, I can connect to the board, I see the DFU button but it does not upgrade. I attach the source code and the prj.conf file

    Thanks for your suggestions to solve this other problem.5460.prj.conf

    /*
     * Copyright (c) 2016 Intel Corporation
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr.h>
    #include <stats/stats.h>
    #include <device.h>
    #include <devicetree.h>
    #include <drivers/gpio.h>
    #include <bluetooth/bluetooth.h>
    #include <bluetooth/hci.h>
    #include <bluetooth/gap.h>
    #include "common.h"
    /* 1000 msec = 1 sec */
    #define SLEEP_TIME_MS 100
    
    /* The devicetree node identifier for the "led0" alias. */
    #define LED0_NODE DT_ALIAS(ledh)
    
    #if DT_NODE_HAS_STATUS(LED0_NODE, okay)
    #define LED0	DT_GPIO_LABEL(LED0_NODE, gpios)
    #define PIN	DT_GPIO_PIN(LED0_NODE, gpios)
    #define FLAGS	DT_GPIO_FLAGS(LED0_NODE, gpios)
    #else
    /* A build error here means your board isn't set up to blink an LED. */
    #error "Unsupported board: led0 devicetree alias is not defined"
    #define LED0	""
    #define PIN	0
    #define FLAGS	0
    #endif
    
    
    
    #ifdef CONFIG_MCUMGR_CMD_FS_MGMT
    #include <device.h>
    #include <fs/fs.h>
    #include "fs_mgmt/fs_mgmt.h"
    #include <fs/littlefs.h>
    #endif
    #ifdef CONFIG_MCUMGR_CMD_OS_MGMT
    #include "os_mgmt/os_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_IMG_MGMT
    #include "img_mgmt/img_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_STAT_MGMT
    #include "stat_mgmt/stat_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_SMP_BT
    #include "mgmt\mcumgr\smp_bt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_SHELL_MGMT
    #include "shell_mgmt/shell_mgmt.h"
    #endif
    #ifdef CONFIG_MCUMGR_CMD_FS_MGMT
    #include "fs_mgmt/fs_mgmt.h"
    #endif
    
    void main(void)
    {
     const struct device *dev;
     bool led_is_on = true;
     int ret;
     /*
     NRF_CLOCK-> LFCLKSRC = 0;
     NRF_CLOCK->LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
     NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
     NRF_CLOCK->TASKS_LFCLKSTART    = 1;
    
    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
    {
        // Do nothing.
    }
    */
    
     os_mgmt_register_group();
     img_mgmt_register_group();
     smp_bt_register();
     
     #ifdef CONFIG_MCUMGR_SMP_BT
    	start_smp_bluetooth();
     #endif
    
            dev = device_get_binding(LED0);
    	if (dev == NULL) {
    		return;
    	}
    
    	ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
    	if (ret < 0) {
    		return;
    	}
    
    	while (1) {
    		gpio_pin_set(dev, PIN, (int)led_is_on);
    		led_is_on = !led_is_on;
    		k_msleep(SLEEP_TIME_MS);
                    STATS_INC(smp_svr_stats, ticks);
    	}
    }
    

Children
Related