# NRF52832 開發 **紀錄一些開發用到的工具:** 開發板: 青風藍芽開發板 程式開發界面(IDE): uvision 5 問題: uart需用於別的用途,需找尋其他方法印出除錯訊息 解決方案: 引用SEGGER_RTT替代uart to usb 印出除錯訊息 按照一下步驟將\Program Files (x86)\SEGGER\JLink\Samples\RTT底下的SEGGER_RTT_V688a.rar解壓縮,之後將底下的RTT目錄底下會有四個檔案 * SEGGER_RTT.c * SEGGER_RTT.h * SEGGER_RTT_printf.c * SEGGER_RTT_Conf.h 將這個資料夾按照下面的步驟加入到專案的引用路徑中 1. 需在開發專案上按右鍵,找尋options for target nrf52832_xxaa 2. 切到C\C_++的tab 3. 選擇include paths 4. 將放置RRTTTT相關函式的目錄加入 之後便可在程式中透過#include "SEGGER_RTT.h"引用SEGGER_RTT_printf函式。SEGGER_RTT_printf需注意要在地一個參數引用console數字才並且配合JLINK RTT VIEWER這個軟體才可以正常運作。 ## 使用linux工具測試nrf52的uart功能 使用**stty**設定usb-uart dongle的參數: ```bash= stty -F /dev/ttyUSB0 -onlcr #關閉將LF變為LFCR stty -F /dev/ttyUSB0 115200 ``` ## 使用echo輸出存hex資料 ```bash= echo -en "\x55\xaa\x00\x02\x00\x00\x01" > /dev/ttyUSB0 # -e:允許以反斜線的特殊字元 # -n:在輸出末端關閉換行字元 ``` ## uart在communicatino error 可在C\C++加入DEBUG巨集印入更詳細的除錯訊息。 ## nrf52832 低功耗機制 **參考**[NRF52832學習筆記(33)——低功耗實現](https://tw511.com/a/01/17401.html) ## 內部震盪參數調整(自行開發的 nrf52832 dongle) 如果要使用內部RC震盪需要調整下列sdk_config.h裡的參數 **以下在nRF_SoftDevice裡面:** 1. NRF_SDH_CLOCK_LF_SRC-SoftDevice clock source:NRF_CLOCK_LF_SRC_RC(預設**NRF_CLOCK_LF_SRC_XTAL**) 2. NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval:16(預設**0**) 3. NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval under constant temperature:16(預設**0**) 4. NRF_SDH_CLOCK_LF_ACCURACY - External clock accuracy used in the LL to compute the timing:NRF_CLOCK_LF_ACCURACY_500_PPM(預設**20_PPM**) **以下在nRF_Drivers裡面:** 1. CLOCK_CONFIG_LF_SRC-LF Clock Source:RC(預設為**XTAL**) ## 註解掉的nrf_pwr_mgmt_註解掉的()需要去處理 **參考資料:** 1. [Example of using internal oscillator with BLE?](https://devzone.nordicsemi.com/f/nordic-q-a/33416/example-of-using-internal-oscillator-with-ble) 2. [Internal RC Calibration Handling on the Nordic nRF52 Chipset](https://jimmywongiot.com/2019/12/17/internal-rc-calibration-handling-on-the-nordic-nrf52-chipset/) 3. [Change Low Frequency Clock Source #92](https://github.com/platformio/platform-nordicnrf52/issues/92) ## 參考資料 1. [嵌入式開發筆記——除錯元件SEGGER_RTT](https://iter01.com/572237.html) 2. [printf系列教程07_JLink-RTT打印输出配置,基于J-Link](https://www.strongerhuang.com/printf/printf%E7%B3%BB%E5%88%97%E6%95%99%E7%A8%8B07_JLink-RTT%E6%89%93%E5%8D%B0%E8%BE%93%E5%87%BA%E9%85%8D%E7%BD%AE%EF%BC%8C%E5%9F%BA%E4%BA%8EJ-Link%E3%80%8ERTT%20Viewer%E3%80%8F.html) 3. [假日嵌入式系統工程師:SEGGER RTT (2)](http://lihgong.blogspot.com/2016/05/segger-rtt-2.html) 4. [如何调试nRF5 SDK](https://www.cnblogs.com/iini/p/9279618.html) ###### tags: `nrf52` `ble` `uart` `minicom` `stty`