Nordic nRF52840 SDK16 RTT Log

一、Firmware

1. sdk_config.h
#define NRF_LOG_BACKEND_RTT_ENABLED 1
#define NRF_LOG_ENABLED 1
2. header files
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
3. initialization function
void log_init(void)
{
	ret_code_t err_code = NRF_LOG_INIT(NULL);
	APP_ERROR_CHECK(err_code);
	NRF_LOG_DEFAULT_BACKENDS_INIT();
}
4. flush log buffer function
NRF_LOG_PROCESS();
5. main function
int main(void)
{
	log_init();
	NRF_LOG_INFO("RTT_LOG");
	for(;;)
	{
    	if (NRF_LOG_PROCESS() == false)
	    {
	        nrf_pwr_mgmt_run();
	    }
}

二、Software

1. JLink.exe

Nordic nRF52840 SDK16 RTT Log_第1张图片

2. JLink RTT Viewer

Nordic nRF52840 SDK16 RTT Log_第2张图片
Nordic nRF52840 SDK16 RTT Log_第3张图片

你可能感兴趣的:(#,Nordic,Nordic,nRF52840,SDK16,RTT)