Skip to content

Debug Module Usage Guide

Kolosso edited this page Aug 11, 2024 · 14 revisions

The Debug module contains several tools for debugging your program.

Print Macros

There are three print macros included:

  • PRINT_INFO: for printing general debug information.
  • PRINT_ERROR: for printing errors.
  • PRINT_WARN: for printing warnings.

These macros do a few nice things for you:

  • They format your messages in a nice way.
  • They include extra information for errors and warnings.
  • They can be disabled so your program is stripped of all print statements (good for optimizing).

Example

Here's an example program using the print macros:

#include "tuk/tuk.h"

// define the name of the file/module.
#define PRINT_SUBJECT "Main"

int main()
{
  /* HAL init... */
  
  PRINT_INFO("This is a test");
  PRINT_WARN("This is a warning. There's about to be an error!");
  PRINT_ERROR("Ahhh, your board is on fire!");

  int my_integer = 15;
  PRINT_INFO("my_integer = %d", &my_integer);

  return 0;
}

The output would be:

[Main] This is a test
[Main] WARNING: This is a warning. There's about to be an error! ('../Core/Src/main.c':103)
[Main] ERROR: Ahhh, your board is on fire! ('../Core/Src/main.c':104)
[Main] my_integer = 15

Setup

In order to see your program's output, you will need to do some setup in STM32CubeIDE. This article includes step-by-step instructions on how to do that.

Clone this wiki locally