NRF51822之32Mhz

Posted 陌鉎こ城sHi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NRF51822之32Mhz相关的知识,希望对你有一定的参考价值。

硬件平台为微雪BLE400的(将原来的16mhz晶振改为32mhz。两个旁电容改为22pf)

 

以nRF51_SDK_10.0.0_dc26b5e\\examples\\ble_peripheral\\ble_app_uart项目为例

 

在main.c中进行修改

#if defined( USB_SYSTEM_CLOCK_32MHZ)
#define DEVICE_NAME                     "Nordic_UART_32mhz"                               /**< Name of device. Will be included in the advertising data. */
#else
#define DEVICE_NAME                     "Nordic_UART"                               /**< Name of device. Will be included in the advertising data. */
#endif//USB_SYSTEM_CLOCK_32MHZ

#if defined (USB_SYSTEM_CLOCK_32MHZ)
/**@brief Function for Set the external high frequency clock source to 32 MHz .
 */
static void setClock( 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) {}
    
}
#endif//USB_SYSTEM_CLOCK_32MHZ

/**@brief Application main function.
 */
int main(void)
{
    uint32_t err_code;
    bool erase_bonds;
    uint8_t  start_string[] = START_STRING;
#if defined (USB_SYSTEM_CLOCK_32MHZ) setClock(); #endif//USB_SYSTEM_CLOCK_32MHZ

// Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); uart_init(); buttons_leds_init(&erase_bonds); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); printf("%s",start_string); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { power_manage(); } }

修改system_nrf51.C

 

#if defined( USB_SYSTEM_CLOCK_32MHZ)
#define __SYSTEM_CLOCK      (32000000UL)     /*!< nRF51 devices use a fixed System Clock Frequency of 32MHz */
#else
#define __SYSTEM_CLOCK      (16000000UL)     /*!< nRF51 devices use a fixed System Clock Frequency of 16MHz */
#endif//USB_SYSTEM_CLOCK_32MHZ

 后面的测试的步骤和16mhz步骤相同。

 

以上是关于NRF51822之32Mhz的主要内容,如果未能解决你的问题,请参考以下文章

NRF51822之RNG

[异常解决] Keil安装好nRF51822开发环境,运行DEMO报错:Error:“GPIOTE_CONFIG_NUM_OF_LOW_POWER_ENVENTS” is undefined(代码片段

想问一个技术问题,就是nrf51822做蓝牙实验的时候,必须使用32.768khz晶振吗

可以跟NRf51822媲美的蓝牙4.0芯片PHY6202

跟NRF51822对抗的国产芯片PHY6202

NRF51822自学笔记PWM