- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am trying to make DBF_PRINTF macro working on my own project. This macro seems to be used in multiple example projects but I can't figure out all details how to make it working.
Attached is my example project. If someone could see what is missing. It should print "Hello World!" from uart but it is printing nothing and program execution seem to hang on this line:
DBG_PRINTF("Hello World!\r\n");
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Common.h is missing in your program. This is missing /***************************************
* Conditional Compilation Parameters
***************************************/
#define DEBUG_UART_ENABLED ENABLED
This is missing
/***************************************
* Macros
***************************************/
#if (DEBUG_UART_ENABLED == ENABLED)
#define DBG_PRINTF(...) (printf(__VA_ARGS__))
#else
#define DBG_PRINTF(...)
#endif /* (DEBUG_UART_ENABLED == ENABLED) */
and this
#if (DEBUG_UART_ENABLED == ENABLED)
and this /* 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_UartPutChar(*ptr++);
}
return len;
}
and this
#endif /* DEBUG_UART_ENABLED == ENABLED */
void ShowValue(CYBLE_GATT_VALUE_T *value)
{
int16 i;
for(i = 0; i < value->len; i++)
{
DBG_PRINTF("%2.2x ", value->val);
}
DBG_PRINTF("\r\n");
} there is probably other but I would take this program and then add your program in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bobgoar,
Your fixes did not change the behavior of application. It is still printing nothing.
Reason why I would like to have like to have this is to simplify printing own text and variable values on same strings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can I ask why you are not using Cysmart to debug the program? It works very well and you can read out all the variables with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use sometimes PSOC creator and Cysmart for debugging, but sometimes I would like to run application at full speed and see what is happening by looking a debug prints.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know this technique is used in many examples, but despite of hard trying I haven't get it working on my application. If I look the source code files, it seems that I have all needed blocks.
I understand that it should work like this:
-fucntion "int _write(int file, char *ptr, int len)" should eventually write the data to debug channel, but is never called explicitly on any soucre.
- #define DBG_PRINTF(...) (printf(__VA_ARGS__)) taking input parameter from DBG_PRINTF and if needed split it to formatting string + parameters for printf
-Then content of "printf" should be passed to "int _write(int file, char *ptr, int len)" Should I define this in some other place than source code? Looking the source codes of multiple example project looks like this linking is done automatically or defined elsewhere.
If you see some parts missing on my code, could you tell exactly what it is. I cannot see the missing parts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Common.h is missing in your program. This is missing /***************************************
* Conditional Compilation Parameters
***************************************/
#define DEBUG_UART_ENABLED ENABLED
This is missing
/***************************************
* Macros
***************************************/
#if (DEBUG_UART_ENABLED == ENABLED)
#define DBG_PRINTF(...) (printf(__VA_ARGS__))
#else
#define DBG_PRINTF(...)
#endif /* (DEBUG_UART_ENABLED == ENABLED) */
and this
#if (DEBUG_UART_ENABLED == ENABLED)
and this /* 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_UartPutChar(*ptr++);
}
return len;
}
and this
#endif /* DEBUG_UART_ENABLED == ENABLED */
void ShowValue(CYBLE_GATT_VALUE_T *value)
{
int16 i;
for(i = 0; i < value->len; i++)
{
DBG_PRINTF("%2.2x ", value->val);
}
DBG_PRINTF("\r\n");
} there is probably other but I would take this program and then add your program in it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use sometimes BLE dongle as my development environment if Pioneer board is attached to some other development kits. I do not see any issue there if I just configure IOs correctly.
And there was nothing relevant missing on the my codes. Of course I remove header files that are not anyhow related to issue, to make my point clear. Problem seems to be something that is not visible on source codes.
Attached two project are identical from source code point of view. Other prints debug messages correctly other does not print anything. The working one is made by shrinking some example codes containing DBG_PRINTF. Then the non-working one is started from scratch and all source code is copy pasted from working one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check the heap size, it is different between the projects.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the program that doesn't work has a heap size of 080 and the one that works is 0400. So it is the heap size that is the issue,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Bobsies,
Chancing the heap size really seems to solve the problem. Why is it so? Is there a way to easily detect correct amount of heap and stack memory for my application?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I also met the same problem,thank you very much!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
printf() needs some memory temporarily and allocates it using the standard methods as sbrk() man / or malloc().
The question is not "How big should be the heap", but "How big to set the stack". The room for global and static vars is reserved automatically, the heap should be set as required (more or less a guess) and the rest? You cannot do anything with the remaining sram but use it as the heap.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
just wondering if this was resolved, I now have the same issue. I think I coppied, all the source files and code properly, I do a Uart_Start() at the begining of the main program to initialize the uart and when I do a printf, the program hangs as it appears to be missing something, but the compiler gives me no errors, this is a very basic thing that should work, it is the most common debugging procedure ever used, run a uart out somewhere to do printf statements to check the status of your program, like status and state machine conditions. where the BLE dongle and Cysmart are of no use. meaning the problem is not with BLE but in your actual application not in bluetooth communications. At this point in time it is unclear if there is a tool generated file missing, or some kind of manual code missing. Is there a basic App Note for how this works?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Post your project with the uart not-working and please mention which development kit you use, I'll check it.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am facing similar problem . When i am trying to print the statement using
UART_DEB_UartPutString("TEST");
I can see " TEST" in my tera terminal .
DBG_PRINTF("TEST \r\n");
I cannot see anything in the terminal and program counter goes to
CY_ISR(IntDefaultHandler)
{
/***************************************************************************
* We must not get here. If we do, a serious problem occurs, so go into
* an infinite loop.
***************************************************************************/
#ifdef CY_BOOT_INT_DEFAULT_HANDLER_EXCEPTION_ENTRY_CALLBACK
CyBoot_IntDefaultHandler_Exception_EntryCallback();
#endif /* CY_BOOT_INT_DEFAULT_HANDLER_EXCEPTION_ENTRY_CALLBACK */
while(1)
{
}
}
Can U please let me what to do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum.
I always use a combination of sprintf() and putstring. in your case it would be
char Buffer[50];
sprintf(Buffer,"Test\r\n");
UART_DEB_UartPutString(Buffer);
When printing float values, do not forget to allow for newlib nano float formatting (in project options) and setting the heap size to 0x0200 (in .cydwr view, system tab)
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This solved my problem too... Thank you..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Welcome in the forum, Narayan!
Happy coding.
Bob