Enabling Logging in CCS¶
The log driver may be used to easily add debug logging capabilities
to any project. The main benefit of the log driver is operates
entirely through JTAG which means that no UART peripherals are necessary
to enable the logging functionality. In other words, you do not have
to use up a UART peripheral or modify your project’s UART operation
to enable debug logging for your debugging purposes.
Setting up the Logging Functionality¶
To start, import the desired project into CCS.
For this example, Basic BLE project will be used.
Next, add
${COM_TI_SIMPLELINK_LOWPOWER_F3_SDK_INSTALL_DIR}/source/ti/log/lib/ticlang/m0p/log_cc23x0r5.ato the File Search Path, which is found by right clicking the project →Properties→Build→Arm Linker→File Search. Click the add icon to add the path. The properties tab should look like the image below when completed correctly. After adding the file path, click Apply and Close.
Add
ti_log_Log_ENABLEto the Predefined Symbols. This is also found within the properties of the project. Right click the project →properties→Build→Arm Compiler→Predefined Symbols. Add this with the paper icon with the green plus. The properties tab should look like the image below when completed correctly. After adding the predefined symbol, click Apply and Close.
Setting up Log Modules¶
Open the Basic BLE SysConfig file. The logging module is configured through SysConfig. Under
LOGGING, is a section for log modules. Here, the log modules will be added. Once in the Log Modules SysConfig section, click onADDto add a Log Module instance. Name the moduleLogModule_App1. Within this module, make sure theEnable Modulecheck box is checked. Next check theEnable Level DEBUG,Enable Level VERBOSE, andEnable Level INFO. Make set the sink to/ti/log/LogSinkBufand ensureLogger Sink Instanceis set toCONFIG_ti_log_LogSinkBuf_0.The module will look like the following if the previous steps are followed.
Within the
Global Parameterssection checkGlobal Enable Module, then under theGlobal Log Level Configurationsubsection, checkEnable Level DEBUG,Enable Level VERBOSE, andEnable Level INFOCheck
LOG SINKSmodule in SysConfig, and verify the name is properly set:
To test the log function, add the code below into the main function.
1Log_printf(LogModule_App1, Log_DEBUG, "Hello world");
Add also the following include:
1#include <log/Log.h>
Once this is done, debug and flash the program to the board. While the board is in debug mode, you may open the log by going to
Tools→Runtime Object View. After ROV is open, click onLogSinkBufwithin ROV, and set theLogSinkBuftoRecords, and then click the continuous refresh button to keep the log constantly updating. It should look like this:
This completes the basic set up for the logging functionality. Additionally, more Log_printf
can be added in various locations to indicate different tasks. The debug level may be changed
or outright disabled during debugging depending on which parts of the programs you want to debug
or would like to receive messages for.
For more information on the log function, make sure to reference the Log Example for a drivers-only example that contains the logging functinoality. The readme for the example also provides valuable insight into how the log driver works and how you can use it in your custom project.