[Nordic] Frequently Asked Questions about Using nRF52810

Question 1: Nordic calls the Bluetooth protocol stack Crash problem

Problem description: After initializationble_stack_init(), the program will be stuck and cannot run normally. After multiple verifications, the location of Crash is located as follows:

ret_code_t nrf_sdh_enable_request(void)
{
    
    
	......
    nrf_clock_lf_cfg_t const clock_lf_cfg =
    {
    
    
        .source       = NRF_SDH_CLOCK_LF_SRC,
        .rc_ctiv      = NRF_SDH_CLOCK_LF_RC_CTIV,
        .rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV,
        .accuracy     = NRF_SDH_CLOCK_LF_ACCURACY
    };

    CRITICAL_REGION_ENTER();
#ifdef ANT_LICENSE_KEY
    ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler, ANT_LICENSE_KEY);
#else
    ret_code = sd_softdevice_enable(&clock_lf_cfg, app_error_fault_handler); // 程序每次运行到这里被卡死
#endif
	......
}

Solution:
Need to configure the LFCLK clock source as the internal clockNRF_SDH_CLOCK_LF_SRC = NRF_CLOCK_LF_SRC_RC, and set the timing clock calibration intervalNRF_SDH_CLOCK_LF_RC_CTIVto 16 .

Remarks: Why do you need such a setting, please refer to the following problem analysis.

  • method 1:
    Insert picture description here
  • Method 2:
    Insert picture description here
    Problem analysis:
    After the Bluetooth protocol is called, it will be stuck mainly because the clock configuration is wrong, and the software configuration does not match the actual hardware. For the relevant configuration of Clock control, we can refer to the official document "nRF52810_PS_v1.3.pdf" . The picture of nRF52 series is Clock controlas follows:

Insert picture description here
From the above figure, we can know that Clock control is mainly divided into two parts: HFCLK (high frequency clock) and LFCLK (low frequency clock). Generally, the problem is the 32.768kHz of LFCLK . In order to reduce the cost, the 32.768kHz external crystal will be omitted and the internal crystal will be used. There are 3 sources for LFCLK to choose from:

  • 32.768 kHz RC oscillator ( LFRC ) //Use internal crystal LFRC to generate 32.768kHz LFCLK clock
  • 32.768 kHz crystal oscillator ( LFXO ) //Use external crystal LFXO to generate 32.768kHz LFCLK clock
  • 32.768 kHz synthesized from HFCLK ( LFSYNT ) //Use internal HFCLK frequency division to generate 32.768kHz LFCLK clock
Clock source Pros and cons Remarks
LFRC Advantages : low cost Disadvantages : low accuracy, susceptible to temperature
Because it is easily affected by the external environment and has low accuracy, timing calibration is required.
The calibration is to calibrate the LFRC by turning on the HCLK regularly.
LFXO Advantages : high accuracy, not easy to receive interference. Disadvantages : increased hardware costs
In this way, the clock accuracy is relatively high, but it will increase the hardware cost.
LFSYNT Advantages : low cost, relatively high accuracy. Disadvantage : increase power consumption
Using this method will cause HFCLK to be turned on for a long time, resulting in increased power consumption.

Remarks: Set according to the actual hardware scheme and requirements NRF_SDH_CLOCK_LF_SRC, you can solve the stuck problem encountered above.

Question 2: How to use MDK to download HEX files of Application and SoftDevice

Nordic's nRF52 series platform is generally divided into two parts:

  • Application: Mainly the Hex file of the application generated by our programming;
  • SoftDevice: This is the Hex file of the Bluetooth protocol stack provided by Nordic's official website, and its API can be called directly during programming;

The memory partition is roughly as follows:
Insert picture description here

  1. Application program download
    Use Nordic official SDK test sample test, the path is as follows:nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_uart\pca10040e\s112\arm5_no_packs
    • Open the ble_app_uart project through MDK.
    • Open the magic wand in MDK, as shown below:
      -
    • Switch to the "Utilities" tab in the pop-up window, and then click "Setting" to open the programming algorithm window. (Note: No need to modify to use the default configuration)
      -
    • Compile the project and click to download the application to the development board after the compilation is successful.
      Insert picture description here
  2. SoftDevice Bluetooth protocol stack program download
    Use Nordic official SDK test sample test, the path is as follows:nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_uart\pca10040e\s112\arm5_no_packs
    • Open the ble_app_uart project through MDK.
    • Switch to the project to download the protocol stack
      Insert picture description here
    • Open the magic wand in MDK, as shown below:
      Insert picture description here
    • Switch to the "Utilities" tab in the pop-up window, and then click "Setting" to open the programming algorithm window. (Note: Will be nRF52xxmodified to nRF52xx SoftDevice Erase)
      Insert picture description here
    • Click the download button to download the protocol stack.
      Insert picture description here

Remarks: The general programming sequence is:

  • Erase Flash partition // MDK toolbar "Flash" --> "Erase"
  • Burn the Hex file of the SoftDevice Bluetooth protocol stack
  • Burn Hex file of Application program

Question 3: How to use JFlash to download HEX files of Application and SoftDevice

J-Flash is a separate Flash burning software released by SEGGER (J-Link emulator manufacturer), which supports HEX and BIN format files to be burned to Flash. The J-Flash programming speed is extremely fast, much faster than the download software nRFgo Studio provided by Nordic. What I am showing here is SEGGER J-Flash Lite , because it is relatively small and easy to operate compared to J-Flash .

1. Open the J-Flash Lite software tool
Insert picture description here
2. Select the Device we need to download, enter it in the input box under Manufacturer nordic Semi, and then all Nordic related ICs will be displayed, and nRF52810 will be selected.
Insert picture description here
3. Select Interface as SWD, and click OK.
Insert picture description here
4. Click the Erase Chipbutton to erase the entire chip.
Insert picture description here
4. Select the HEX file of Application and SoftDevice to be downloaded, and then click the Program Devicebutton to download the firmware.
Insert picture description here

Remarks: Because the downloaded Hex file contains the downloaded Flash address information, there is no need to worry that burning two Hex files will erase the data of the other Hex file. Unless the HEX address generated by compiling Application and the HEX file address of SoftDevice are duplicated.

Question 4: How to choose SoftDevice version for nRF52810

It is introduced in "nRF52810 product brief.pdf"nRF52810SoftDevice compatible version, BT protocol stack related to that S112, S132, ANT protocol stack relevance is S212, S312. The details are as follows:
Insert picture description here
S112and S132both support the Bluetooth 5 protocol stack, the differences between them are as follows:

Version Description
S112 Support Bluetooth 5.1 single-mode BLE protocol stack:
• Peripheral x 4
• Broadcaster x 1
S132 Support Bluetooth 5.1 single-mode BLE protocol stack:
• Central
• Observer
• Peripheral
• Broadcaster

Remarks: just needPeripheralMode, generally select S112 . If you need supportCentralPattern orCentral & PeripheralMode, generally select S132 .

Question 5: How to use Nordic NRF Log

  1. There are 2 default printing methods :

    • The way of serial port printing, that is, the way of printf()
    • JLink's RTT Log printing method
  2. If you choose JLink's RTT Log printing method, you need to add SEGGER related files to the project :
    Insert picture description here

  3. Configuration in the sdk_config.h file:

    • NRF_LOG_BACKEND_RTT_ENABLED Set to 1
    • NRF_LOG_BACKEND_UART_ENABLED Set to 0 (no need to set)
  4. Open JLinkRTTViewer.exe
    Insert picture description here
    Insert picture description here

Guess you like

Origin blog.csdn.net/ZHONGCAI0901/article/details/110955946