Skip to main content
Senior
Solved

Hardware/firmware guidelines for reading UBS-C CC lines with ADC?

Hi!

 

I’m slowly working my way through a design in which I plan to use the TCPP01-M12; my device is a USB-C sink, and I don’t intend to utilize any USB-PD negotiation. I have a conflict with my chosen MCU and the UCPD peripheral (the pins of this peripheral need to be allocated to another use), so I am interested in being able to read the CC lines of the USB connection to understand the power capabilities of the upstream source, without dealing with any actual CC communication. 

 

The datasheet for the TCPP01-M12 shows this exact use, on Page. 18, Figure 20. As I understand it, I can use my ADCs to read the voltages on the CC pins to calculate the current delivery capability of the source. What confuses me, however, is that apparently the source will also try to start communicating over the CC lines on connection. As I understand it, this communication happens at a logic level of between 0-1V or so, regardless of the actual current carrying capabilities. 


The obvious problem is that if I sample the CC lines with my ADCs at the wrong time, I’d read invalid/incorrect voltage values, and have a false understanding of the source.

 

I’m finding it tricky to find resources that describe how I might be able to do this properly. I’m curious if anyone else has done this, and if so, how did the CC reading part of things work? 

 

Thanks!

This topic has been closed for replies.
Didier HERROUIN
Didier HERROUINBest answer
ST Technical Moderator

Dear sb_st, dear LCE,

We strongly recommend to add a protection device between the USB-C connector and your µController, for several reasons:

  • It will protect your µController against ESD occurring on VBUS and CC lines
  • It will protect your circuit against overvoltage on VBUS (due residual voltage if the charger previously supplied a high voltage) up to 28V and against overvoltage on CC lines in case of short-circuit with VBUS in the connector (it has been observed and documented on the web).
  • It integrates a VBUS switch driver, to isolate the rest of your circuit from unexpected voltages on VBUS (in case of defective chargers)
  • It integrates the dead battery feature (for battery-powered devices), to be able to start the charge even if the battery is fully depleted, with no leakage when charger is not plugged

For your specific demand, you can use the TCPP01 as you did, and measure the CC1 and CC2 line voltage with ADCs. You can repeat/average the measurements to exclude the moment where CCx line toggle due to BMC messages sent by the SOURCE.

The other option is to use the STUSB4500L : it is a standalone chipset which will protect the circuit, manage the switch closing, monitor VBUS and provide information (through 2 GPIOs) to the µController about the Source capability (900mA, 1.5A or 3A).

Best regards

 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.

11 replies

mƎALLEm
ST Technical Moderator

Hello ​@sb_st ,

You are talking about TCPP01-M12, could you please tell why are you posting that question on STM32 MCU products forum board?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
sb_stAuthor
Senior

Hi;

 

Well, I suppose: I found this example in the TCPP01 datasheet, but my question is not actually about the TCPP01 - it’s about how to sample the CC lines via an ADC. My apologies that the subject line is misleading (which I realize only in hindsight). It’s not evident to me how I can go about modifying/correcting the subject...

Andrew Neil
Super User

It’s not evident to me how I can go about modifying/correcting the subject...

See:

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
ST Technical Moderator

Hi ​@sb_st 

 

A PD capable source may send BMC signaling on CC after detecting Rd, so a direct ADC sample can be misleading. I assume X-CUBE-TCPP includes the exact application you need. I think this thread should be moved to Embedded Software forum.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
sb_stAuthor
Senior

I understand,  yes - that’s sort of the basis of my question. And I’m curious how much this intersects with my hardware design - like, would lowpass filtering be applicable/useful in this situation?

Trying to muddle through this with Claude - it is suggesting that a lowpass filter is unlikely to mitigate the BMC signaling, as that signaling happens at a different voltage level than some of the default contract voltages. But it still recommends SOME filtering, and it suggests taking multiple samples with an ADC, then using a median function to identify a “good” sample from the BMC messaging ones. 

 

I was hoping to get the perspective of a human rather than AI, however, for obvious reasons. The example you mention does seem like it might hold some answers for me - thanks so much! 

I don’t really know where the best forum is to ask this question.

LCE
Principal III

Why do you want to use the TCPP in the first place?

If you don’t communicate, I’m pretty sure you get the minimum 5V / 1.5A from USB-C.

 

I have a design with a USB-C connector only using USB 2.0 communication, and I only need the above minimum power.

To find out what the USB host can deliver, the CC pins are pulled down with 5k1, these signals go to the STM32H7 ADC.

In my schematics I find this note:

CC pull-ups to 5V at host:
56k -> Vucc < 0.45V -> 0.5 A
22k -> Vucc < 0.95V -> 1.5 A
10k -> Vucc < 1.69V -> 3.0 A

… and this is what I find in real life when connecting to either a USB-C or USB 2 port.

I have the H7 ADC running all the time in the background with circular DMA for monitoring about 8 supply voltages, about every 300 ms I check the DMA buffer and do some comparisons, including the CC pins.

Didier HERROUIN
Didier HERROUINBest answer
ST Technical Moderator

Dear sb_st, dear LCE,

We strongly recommend to add a protection device between the USB-C connector and your µController, for several reasons:

  • It will protect your µController against ESD occurring on VBUS and CC lines
  • It will protect your circuit against overvoltage on VBUS (due residual voltage if the charger previously supplied a high voltage) up to 28V and against overvoltage on CC lines in case of short-circuit with VBUS in the connector (it has been observed and documented on the web).
  • It integrates a VBUS switch driver, to isolate the rest of your circuit from unexpected voltages on VBUS (in case of defective chargers)
  • It integrates the dead battery feature (for battery-powered devices), to be able to start the charge even if the battery is fully depleted, with no leakage when charger is not plugged

For your specific demand, you can use the TCPP01 as you did, and measure the CC1 and CC2 line voltage with ADCs. You can repeat/average the measurements to exclude the moment where CCx line toggle due to BMC messages sent by the SOURCE.

The other option is to use the STUSB4500L : it is a standalone chipset which will protect the circuit, manage the switch closing, monitor VBUS and provide information (through 2 GPIOs) to the µController about the Source capability (900mA, 1.5A or 3A).

Best regards

 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
LCE
Principal III

ESD protection: absolutely!

Every connection to the “outside world” must be protected.

It’s even an ST part I use here - although low cap would not be required here, with the 100p anyway... :D

 

Didier HERROUIN
ST Technical Moderator

Better to take some margins around the nominal voltage expected on CC lines, for instance :

  • 0.5A for 0.25V < Vcc < 0.61V (typical value = 0.42V)
  • 1.5A for 0.7V < Vcc < 1.16V (typical value = 0.94V)
  • 3A for 1.23V < Vcc < 2.04V (typical value = 1.69V)

The gap bands between the states defined above allow to reject false detections and transitory states.

Best regards,

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
LCE
Principal III

Absolutely! That’s just my note in the schematics, the firmware takes the +-5% (?) by the specs and ADC inaccuracy into account.