7 Replies Latest reply on Mar 29, 2020 8:05 PM by ShifangZ_26

    printf

    JoBo_4573796

      I am using the PSoC Creator 3.3 and the default notebook project for the CY4541 EX-PD CCG4 Evaluation Kit.  I have a MiniProg3 debugger/programmer.  I can set breakpoint, but is there any way to print statements to a debug console?  The project seems to be ok with including <stdio.h> and printf("Hello World") but will not compile.

        • 1. Re: printf
          ShifangZ_26

          The way we are recommend is add Software UART TX to debug the firmware.  The recommend way is below:

           

          UART debug for firmware bring up or test.

          Open CCGx Project and make sure one of SWD clock / data or other GPIO is available ( using SWD is more convenient, because most design reserve SWD for programming ). Use CCG3PA as example,

          Drag “Software Transmit UART” from component catalog into TopDesign.cysch. And then assigned to SWD_CLK or SWD_DATA.

           

          Call SW_TX_UART_1_Start() in main.c . Sending “start” is to make sure UART is working.

           

          NOW, you add anywhere to output the value (Char, string, or others).

          -----------------------------------------------------------------------------------------------------------

          Now you could build the FW and use UART cable ( or USB to Serial cable ) to connect cable_RX (UART_RX) to SWD_Data (UART_TX)

           

          (Cypress USB to Serial kit (CYUSBS232) is can be re-used for USB to UART TX).

           

          You need a software like Tera Term. And then, configure the UART port to receive the data from CCGx.

           

          Best Regards,

          Lisa

          • 2. Re: printf
            JoBo_4573796

            This was close, but did not work on the 2 CY4541 CCG4 kits that I have.  For whatever reason, both kits are off significantly in the baud rate.  In order to get it to work most of the time, I had to set the baud rate of the CCG4 kit to 19200 and the Tera Term baud rate to 14400.  It seems this UART is off for some reason.  When setting at 19200, the baud rate measures on the scope to be 64.2 us/bit instead of 52.1.  When setting at 115200, the baud rate measures on the scope to be 11 us/bit instead of 8.7 us.  By setting the tera term to 14400 (69.4 us/bit), it is close enough to the 64.2 us/bit that the CCG4 kit is generating to work most of the time.

            • 3. Re: printf
              ShifangZ_26

              May I know what's firmware build version on your end? Is the HFCLK in your design is 48MHz and divide from IMO or not?

               

              Best Regards,

              Lisa

              • 4. Re: printf
                JoBo_4573796

                The HFCLK is 48 MHz with the source clock of IMO.  I am building with PSoC 3.3 for the CY4541 EX-PD CCG4 Evaluation Kit.  CYPD4225-40LQCI, CCG4, Notebook, Bootloader Base version 0.0.0.58, Firmware version 3.0.0.762.

                • 5. Re: printf
                  ShifangZ_26

                  Could you please kindly share your project in this thread? So that I could take a look.

                   

                  Best Regards,

                  Lisa

                  • 6. Re: printf
                    JoBo_4573796

                    I can share the file.  Where and how do I put it somewhere?

                     

                    I am able now to get the printf to be generated at the correct baud rate.  I am using PS0C Creator 3.3 and there seems to be an issue in the Generated_Source code.  By temporarily changing the cydelayFreqHz parameter used in the assembly code from 48,000,000 to 40,000,000, it will output the correct baud rate on the SW UART pin.  Below is a copy of the clocks.

                    • 7. Re: printf
                      ShifangZ_26

                      Kindly refer below setting:

                       

                      And:

                      Please kindly recovery back to original setting after the debug is complete and generated product hex file.

                       

                      Best Regards,

                      Lisa