You are here

DBG_PRINTF macro | Cypress Semiconductor

DBG_PRINTF macro

Summary: 21 Replies, Latest post by Bob Marlowe on 24 Sep 2016 06:39 AM PDT
Verified Answers: 2
Last post
Log in to post new comments.
ville.tiensuu_1549261's picture
User
26 posts

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");

 

 

user_242978793's picture
User
1200 posts

I fixed some issues in your program and I am sending it back to you.  I am not sure why you are debugging it the way you are.

ville.tiensuu_1549261's picture
User
26 posts

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.

user_242978793's picture
User
1200 posts

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.

ville.tiensuu_1549261's picture
User
26 posts

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.

user_242978793's picture
User
1200 posts

Look at the program I am sending you it works with debug and is producing data on the debug channel.  Looking at this program and your program there appears to be a few parts missing like debug start ect.

ville.tiensuu_1549261's picture
User
26 posts

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.

 

 

 

 

user_242978793's picture
User
1200 posts

Compare the program I just sent you and,make your program just like it . For example your program is missing a .h file another issue your program is using the USB Dongle instead of the Pioneer Ble board and a psoc ble plug in . The example I sent uses the PSOC Ble module. The dongle is for the Cysmart connection with out using a phone.

user_242978793's picture
User
1200 posts

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[i]);
    }
    DBG_PRINTF("\r\n");
} there is probably other but I would take this program and then add your program in  it.

 

 

ville.tiensuu_1549261's picture
User
26 posts

 

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.

user_1377889's picture
User
10103 posts

Check the heap size, it is different between the projects.

 

Bob

Log in to post new comments.