Ralim / STM32-USB-PD-Demo

Black Pill Demo
MIT License
9 stars 4 forks source link

Demo does not work, PDOs are requested but not selected. #1

Open nikolai2111 opened 11 months ago

nikolai2111 commented 11 months ago

Hello,

I am currently working on a project for my bachelor thesis. It is a USB-C PD laboratory power supply. I am currently on the home straight.

Unfortunately, I couldn't get your demo project to work. Because the two devices can't agree on a PDO, or a PDO is requested but it never happens. See picture below. This is the output over the UART: COM3_-_Tera_Term_VT_400-288_2023-12-02_757

This is the voltage on the VBUS: WaveForms_(new_workspace)_1920-1017_2023-12-02_758

And here is the output of the STM32CubeMonitor USB-C PD: STM32CubeMonitor-UCPD_1 2 0_1920-1017_2023-12-02_756

Can you help me? I'm planning to open-source the project when it's finished, so your usb-pd part would be perfect.

Ralim commented 11 months ago

Hia, To confirm are you using a black pill board with all the IO wired up as mentioned in the Readme? When I last updated this project it was working to request a connection. You may have a power supply that advertises 21V max in the PPS profile but cant supply it. Try disabling this if block section https://github.com/Ralim/STM32-USB-PD-Demo/blob/58fcba925cb40cd79dd307f3b30fd32ffb364d06/Workspace/USBPDDemo/Core/user/PDUser.cpp#L98

If that is the case, just limit the max requested voltage to 20V

nikolai2111 commented 11 months ago

Hello,

Thanks for your fast response. No I'm not using a Black Pill Board, I'm using an own Board. But I'm pretty sure the connection are right, because I tested them already.

I have tested the program without the "else if" statement which you suggested, but no success.

Could it also be a malfunctioning interrupt, because I misconfigured something?

nikolai2111 commented 11 months ago

Edit: I also tested if the interrupt comes through, and it does. When I plug in the connector I will land in this function. So I'm sure the hardware is working correct.

https://github.com/Ralim/STM32-USB-PD-Demo/blob/58fcba925cb40cd79dd307f3b30fd32ffb364d06/Workspace/USBPDDemo/Core/user/PDUser.cpp#L56

nikolai2111 commented 11 months ago

The Log on the UART-Interface with the PD_DEBUG_OUTPUT defined. Looks like the following:

Starting
FUSB Comms OK
>Running thread
Current state - PESinkDiscovery
Current state - PESinkSetupWaitCap
Waiting for events 0023
>Waiting for events
>Running thread
>Waiting for events
>Running thread
>Waiting for events
>Running thread
>Waiting for events
Notification received  0800
Notification received  0002
>Running thread
Current state - PESinkWaitCap
Wait Cap Event 0802
Source Capabilities message RX
Current state - PESinkEvalCap
PD slot 0 -> 5000 mV; 3000 mA
PD slot 1 -> 9000 mV; 3000 mA
PD slot 2 -> 12000 mV; 3000 mA
PD slot 3 -> 15000 mV; 3000 mA
PD slot 4 -> 20000 mV; 5000 mA
Found desired capability at index  4, 20000 mV, 5000 mA
Current state - PESinkSelectCapTx
Sending desired capability
Starting message Tx - 02
Message queued to send
Waiting for events 0E01
>Waiting for events
>Running thread
>Waiting for events
>Running thread
>Waiting for events
...

Edit: It looks like the device gets detached, with both USB-C sources I have. STM32CubeMonitor-UCPD_1 3 0_1257-304_2023-12-08_581

Ralim commented 11 months ago

So the uart logs show that it is attempting to send the message back but your not seeing it in your logger. Are you able to capture the I2C bus traffic?

nikolai2111 commented 11 months ago

Yes, I captured it today. I started the capture, then reseted the device, then plugged in the USB-C cable.

USB-C_PS_I2C-Log.txt

The circuit diagram looks like this. I have placed R401 as it does not work, but I have in mind, that this Connection to VBUS is not needed. Is that correct? A 220pF capacitor is connected to each of the CC lines. image