semf
Debug

General

Having errors in a source code is always a pain. Debugging is time consuming but most of the time leads to the goal. To have simple debugging messages available and make it more efficient we added a method to semf where you can easily get messages from the semf library if an error in the target hardware or in the library occurres.

Initialization

First define USE_SEMF_ASSERT. The best way to do that is to add it as a Symbol in the project settings (e.g. Project -> Properties -> C/C++ General -> Paths and Symbols -> Symbols in Eclipse based IDEs).

Secondly implement the assertFailed function in your project, for example in the maincpp.cpp file.

void semf::assertFailed(DebugId debugId)
{
// Option 1: End here if an error occurres and check the debugId
while(1);
// Option 2: Use printf to send the debugIds through e.g. SWD or UART to the computer
printf("%i\n",debugId);
}

printf

For debugging it is often helpful to have printf functionallity available through e.g. UART or SWD. Refer to your micocontrollers documentation on how to set this up.

Recommended Ressources:

  • STMicroelectronics describes the how-to for UART and SWD in the application note AN4989 (see chapter „printf debugging“).
  • Keil describes a how-to for SWD when using qVision on their website.
  • IAR describes a how-to for SWD when using IAR Embedded Workbench on their website.