- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
it looks simple but didnt work. I want to add printf for debuging.
I used a sample code from a "BLE_Battery_Level" example project.
I have a debug.c file with the following code.
#include <project.h>
#include <stdio.h>
#include "main.h"
/* For GCC compiler revise _write() function for printf functionality */
int _write(int file, char *ptr, int len)
{
int i;
file = file;
for (i = 0; i < len; i++)
{
UART_DEB_PutChar(*ptr++);
}
return len;
}
And in my main.h the following
#include <project.h>
#include <stdio.h>
#if (DEBUG_UART_ENABLED == ENABLED)
#define DBG_PRINTF(...) (printf(__VA_ARGS__))
#else
#define DBG_PRINTF(...)
#endif /* (DEBUG_UART_ENABLED == ENABLED) */
I cant find any different setting in the project build settings. But it will not work.
Any idea?
Thanks a lot
Max
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Hope you are using the UART Component in your design to print Debug messages.
Increase the Heap size to 0x200 (under Design-Wide Resources System tab) and see if that resolves the issue.
if you are trying to print floating-point variables, then in project Build Settings -> Linker set "Use newlib-nano Float Formatting" to True.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Hope you are using the UART Component in your design to print Debug messages.
Increase the Heap size to 0x200 (under Design-Wide Resources System tab) and see if that resolves the issue.
if you are trying to print floating-point variables, then in project Build Settings -> Linker set "Use newlib-nano Float Formatting" to True.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great thank you very much!!
It works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Also remember to do this first:
// Disable IO buffering in libc to avoid putchar() bug
// See: https://bugs.launchpad.net/gcc-arm-embedded/+bug/1380268
setvbuf(stdout, NULL, _IONBF, 0);
Regards,
Pieter