Skip to main content
Visitor II
January 4, 2024
Question

STM32G0 USB PD periphery doesn't send data after extracting code from CubeIDE

  • January 4, 2024
  • 4 replies
  • 2463 views

Hello,
I am developing a USB PD sink product using STM32G0B1VET6 MCU.
I have a project in CubeIDE, created proof-of-concept code following ST tutorial Getting started with USB-Power Delivery Sink and everything works as expected.

I then tried to transfer all of the code into my project (outside of CubeIDE) and it's not working. See the attached trace

The events go as follows:

  1. Source advertises SRC_CAPABILITIES
  2. Sink requests PDO
  3. No answer, sink repeats request 3 more times
  4. Sink requests PE_STATE_SEND_SOFT_RESET
  5. Sometimes, source answers, usually not
  6. After 4 attempts ad soft reset, sink requests hard reset.
  7. Repeat indefinitely

I suspect the sink isn't actually sending any data out.
I tried sniffing the PD bus, and indeed, there is no communication going from sink to source. Maybe something went wrong, when moving the code to different project. Maybe I forgot something.
How do I debug this?

    This topic has been closed for replies.

    4 replies

    Visitor II
    January 12, 2024

    Beware different RTOS, CMSIS, HAL and USB PD lib revisions. They are not compatible. There are now compile-time checks to enforce this and no external documentation either.
    If you want your USB PD to work, make sure you are picking all of the above mentioned components from the same Cube version.

    Technical Moderator
    February 22, 2024

    Hello @Tadeas_Pilar 

    Do you mean after transferring from CubeIDE to another toolchain, you can no longer run your project and you are suspecting the sink no longer able to send data? Would you consider checking the process to port your project?

    Visitor II
    March 1, 2024

    UPDATE: I tried to save a timer and the hack to to that didn't work.

    Long story: USB PD consumes one of the big timers. This is caused by lasy implementation of PD response timing, which needs to be very precise.
    I don't have a big timer to spare, so I rewrote usbpd_timersserver.c to only use one small timer. There was an error in overflow handling. This error, for some reason, didn't manifest itself when I tested in CubeIDE.
    After moving to my project, timing didn't work and PD stack never responded to any messages.
    Debugging this is of course impossible, since the PD stack is closed-source and I can't see what it's stuck on.

    I temporarily solved this issue by going back to ST implementation of usbpd_timersserver.c and giving up some of the required functionality of my project.
    I will eventually have to fix the error and go back to not using a big timer.

    Does ST accept contributions to CubeMX? It might be useful to other people as well.

    Visitor II
    March 1, 2024

    Maybe it should be mentioned somewhere. The STM32G0B1VET6 has 4 big timers, but if you want to use USB-PD, it only has 3.