1 2 Previous Next 19 Replies Latest reply on Sep 24, 2016 6:39 AM by JoMe_264151

    DBG_PRINTF macro




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

        • 1. Re: DBG_PRINTF macro

          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.

          • 2. Re: DBG_PRINTF macro

            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.

            • 3. Re: DBG_PRINTF macro

              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.

              • 4. Re: DBG_PRINTF macro

                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.

                • 5. Re: DBG_PRINTF macro

                  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.

                  • 6. Re: DBG_PRINTF macro

                    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.

                    • 7. Re: DBG_PRINTF macro
                              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.   
                      • 8. Re: DBG_PRINTF macro

                        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__))
                            #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++)
                            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]);
                        } there is probably other but I would take this program and then add your program in  it.

                        • 9. Re: DBG_PRINTF macro

                          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.

                          • 10. Re: DBG_PRINTF macro

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





                            1 of 1 people found this helpful
                            • 11. Re: DBG_PRINTF macro

                              I changed the heap size to 0x400 and your original program is working. Bob was right on the heap size.

                              • 12. Re: DBG_PRINTF macro

                                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,

                                • 13. Re: DBG_PRINTF macro

                                  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?

                                  • 14. Re: DBG_PRINTF macro

                                    I also met the same problem,thank you very much!!!

                                    1 2 Previous Next