How to use printf with System Workbench for STM32
step 1 right click --> properties
step 2 C/C++ build --> Setting
step 3 Select Miscellaneous
step 4 Edit Linker Flags to -specs=nosys.specs -specs=rdimon.specs -lc -lrdimon
step 5 go to Debug and select Debug Config
step 6 ****If you never have been debugging you should double click at Ar6 debugging icon for create debugging for your project *****
step 7 Select run at your debugging project and add massage to Initialization Command
monitor reset halt
step 8 Add this Function to you code for initial debugging by printf
/*
* initial_this function for use printf in debug
*/
#define DEBUG
extern void initialise_monitor_handles(void);
__weak void initial_printf()
{
/*
* properties ->C/C++ Build -> Setting -> Miscellaneous
* and input this text -specs=nosys.specs -specs=rdimon.specs -lc -lrdimon to Linker flags
*/
#ifdef DEBUG
initialise_monitor_handles();
printf("start Debug Mode \n");
#endif
}
int main(void)
{
initial_printf();
while(1)
{ printf("Hello debug") }
}
Enjoy with Debugging by printf
step 5 go to Debug and select Debug Config
step 6 ****If you never have been debugging you should double click at Ar6 debugging icon for create debugging for your project *****
step 7 Select run at your debugging project and add massage to Initialization Command
monitor reset halt
step 8 Add this Function to you code for initial debugging by printf
/*
* initial_this function for use printf in debug
*/
#define DEBUG
extern void initialise_monitor_handles(void);
__weak void initial_printf()
{
/*
* properties ->C/C++ Build -> Setting -> Miscellaneous
* and input this text -specs=nosys.specs -specs=rdimon.specs -lc -lrdimon to Linker flags
*/
#ifdef DEBUG
initialise_monitor_handles();
printf("start Debug Mode \n");
#endif
}
int main(void)
{
initial_printf();
while(1)
{ printf("Hello debug") }
}
result any massage is you want to print will show at Console
Enjoy with Debugging by printf
Comments
Post a Comment