5 Replies Latest reply on Apr 4, 2019 11:51 AM by beyuc_3712261

    the power charge functions not work

    beyuc_3712261

      Hi Lisa,

      I added px_swap.c.zip and px_swap.h.zip in top of the main.c of my project according to your comments below but I don't see the power charge works. could you tell me how I can add the power charge function in my system?

       

      The main.c is attached.

      p1.png

       

      Thanks,

      Derong Yuan

        • 1. Re: the power charge functions not work
          beyuc_3712261

          Hi Lisa again,

          I checked the source code of the project "CYPD3123-40LQXI_ctd_us" which has a function of controlling the signal VBUS_P_CTRL0/1 to let the dc/dc (VBUS_OUT in the diagram below) to charge the device in USB-C connector (C_VBUS).  I found the function "void ctd_us_task(void)" listed in this project is not available in the source code of my project ( based on "CYPD3120-40LQXI_dp_dongle"). The function looks like to detect and control the power charge.

           

          Could you please tell me if /how I can add the function into my project?

          p1.png

           

          Thanks,

          Derong Yuan

          • 2. Re: the power charge functions not work
            ShifangZ_26

            Hi Derong,

             

            1. Even through you are using CYPD3120-40LQXI_dp_dongle and Cypress reference design for CYPD3120 do not have VBUS_P_CTRL and VBUS_C_CTRL hardware circuits. BUT the firmware code is not removed. For your case, you need support power source role, you should have related hardware circuits.

             

            2. For the files to add your project, you just need add .h file to Header folder and .c file to source files folder in creator 3.3. And includes " .h" in main.c file. You could call it same as the answer I was reply.

             

            Anyway, you should make sure your hardware can support your requirements. You could attach your schematic to let me take a look.

             

            Best Regards,

            Lisa

            • 3. Re: the power charge functions not work
              beyuc_3712261

              Hi Lisa,

               

              The CYPD chip used in my project is CYPD3123. Because I use the reference SDK project CYPD3120-40LQXI_dp_dongle I followed Eddie's instruction to change the device name to CYPD3123 from original CYPD3120. I can change it to CYPD3125 if necessary.

               

              I can control two GPIO port P1.0 and P1.1 now. If I can not use the VBUS_P_CTRL0/1 to control the MOSFET switch I would use p1.0 and p1.1 to control. Could you please tell me where in the software to put turn on/off the MOSFET switch to charge the Samsung phone in the USB-C.

               

               

              part of the schematic.

              p1.png

               

               

              The MOSFET switch is turned off before Samsung phone plugged. When the Samsung phone is plugged it provide power to the USB-C so USB hub and Dp-to-HDMI start working.

               

              Then the software should change the power delivery direction and turn on the MOSFET switch to let dc/dc power supply as power source and charge the Samsung in the USB-C.

               

              power delivery diagram (MOSFET switch is U6 in the schematic):

               

              I think I might need to add a USB PD Power Role Swap command sent to Samsung in the USB-C in the event APP_EVT_TYPEC_STARTED or APP_EVT_CONNECT to let Samsung to change to power consuming mode after the MOSFET switch turned on. If so could you please tell me what is the USB PD Power Role Swap command?

               

               

              The VBUS_P_CTRL0/1 are not working with CYPD3123 but 2 GPIOs (p1.0 and P1.1) can be used to turn on/off the MOSFET switch U6. The problems are:

               

              1. if the circuit is powered (U6 is on) when the Samsung plugged to USB-C connector Samsung can be charged but the USB hub and Dp-to-HDMI are not working
              2. if the circuit is not powered (U6 is off) when the Samsung plugged to USB-C connector Samsung can not be changed but the USB hub and Dp-to-HDMI are working.

               

              Can you tell me how I can make the USB hub and Dp-to-HDMI working and Samsung be charged at the same time?

               

              There is another MOSFET switch in the circuit can be used to control the dc/dc regulator (5v/3.3v, 5v/1.2v in the schematic) for USB hub and Dp-to-HDMI converter. If needed the 2 GPIOs can be used to control the MOSFET switch and U6 respectively.

               

              Thanks,

              Derong Yuan

              • 4. Re: the power charge functions not work
                ShifangZ_26

                Hi Derong,

                 

                1. U6 shall be powered, since your design is going to power source. If U6 is not powered, the CCG3 firmware will be in recovery mode for VBUS is abnormal case.

                 

                2. Your next step is,

                a. Make sure the CYPD3120 initial PR_SWAP if it is power sink role at initial states.  And then check VBUS_P_CTRL to confirm the VBUS is enabled.

                b. Make sure the Make sure the CYPD3120 initial DR_SWAP if it is Data Host Role at initial states.

                 

                All of above steps shall be working with PD analyzer and Oscilloscope.

                 

                Best Regards,

                Lisa

                • 5. Re: the power charge functions not work
                  beyuc_3712261

                  Hi Lisa,

                   

                  The CYPD3123 is powered by a dc/dc on board and turned on before Samsung is plugged.

                   

                  Could you tell me if CYPD3123 can be set as power source instead of power sink in recovery mode and the U6 can be turned on in the APP_EVT_CONNECT of  the function void app_event_handler(uint8_t port, app_evt_t evt, const void* dat)?

                   

                   

                  U6 is a PMOSFET functioning as a high-side power switch. The NMOSFET does not work. The power delivery chip is CYPD3123 and the firmware is the reference SDK project CYPD3120-40LQXI_dp_dongle but device name has been changed to CYPD3123 according to EddieZ_31's suggestion:

                  If you want to change device to CYPD3123´╝îplease follow these steps:

                   

                  1. Go TopDesign.cysch page.

                  2. Double click Bootloadable_1 to open Configure 'Bootloadable' dialog.

                  3.Change Bootloadable hex file path to "C:\Program Files (x86)\Cypress\EZ-PD CCGx SDK\CCG3-CCG4\Firmware\projects\CYPD3123-40LQXI_ctd_us\CYPD3123-40LQXI_ctd_us.cydsn\Bootloader\CYPD3123-40LQXI_usb_boot_3_0_2_900_0_0_0_cu.hex". And Bootloader ELF file will be changed to corresponding ELF file automatically.

                  4.Build the project.

                   

                  The voltage of signal VBUS_P_CTRL0/1 is always around 0.1 ~ 0.3v. That is why I use GPIO p1.0 and p1.1 to turn on/off U6.

                   

                  I have tested to set U6  on and off all the time but problem is still there.

                   

                  The cydwr file is below. signal USB_SWITCH_EN is used to control U6.

                   

                  Thanks,

                  Derong Yuan