Checking vbus_in voltage on CCG3PA?

Announcements

Live Webinar: USB-C adoption. Simple & Cost-efficient solutions | April 18th @9am or 5pm CEST. Register now !

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JoLu_3455101
Level 4
Level 4
5 likes given 5 solutions authored 25 replies posted

Hi,

What is the proper way to check the voltage at VBUS_IN_DISCHARGE pin of CCG3PA from firmware?

At first, I tried the function vbus_get_value(port) from the FW API, but it appears that function is checking the voltage from VBUS_C_MON_DISCHARGE pin. I got a reading back of 0mV after power-up when VBUS_IN_DISCHARGE=5V and VBUS_C_DISCHARGE=0V (no device attached). We have back-to-back FETs separating the VBUS_IN_DISCHARGE and VBUS_C_MON_DISCHARGE pins so their voltage can be different.

Thanks,

Jonathan

0 Likes
1 Solution

Hi Jonathan,

Your understand is correct. You could refer below example to read voltage on VBUS_IN_DISCHARGE node.

uint16_t VBUS_IN_measure (uint8_t port)

{

    /* Sample the VCC voltage using ADC. */

    uint8_t level;

    uint16_t retval;

//  Use VBUS_IN monitor VBUS

    PPDSS_REGS_T pd = gl_pdss[port];

    pd->amux_nhv_ctrl |= ((1 << AMUX_ADC_CCG3PA_VBUS_IN_8P_EN_POS) |

    (1 << AMUX_ADC_CCG3PA_VBUS_IN_20P_EN_POS));   

    CyDelayUs(10);   

   

    level = pd_adc_sample(port, APP_VBUS_POLL_ADC_ID, APP_VBUS_POLL_ADC_INPUT);

    retval = pd_adc_get_vbus_voltage(port, APP_VBUS_POLL_ADC_ID, level);

//  Revise back to VBUS_C

    pd->amux_nhv_ctrl &= ~((1 << AMUX_ADC_CCG3PA_VBUS_IN_8P_EN_POS) |

    (1 << AMUX_ADC_CCG3PA_VBUS_IN_20P_EN_POS));

    CyDelayUs(10);

   

    return retval;

}

Best Regards,

Lisa

View solution in original post

0 Likes
4 Replies
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

Hi Jonathan,

May I know what's example firmware you are refer to?

If you are using CYPD3171-24LQXQ_cla or CYPD3175-24LQXQ_pa_direct_fb, the ADC input is wire to VBUS_C_Discharge. And you can see the Application block in the datasheet or CY4532 schematic, the VBUS_C_Discharge is wire to the VBUS node of Type-C interface.

If you are using  CYPD3171-24LQXQ_pb, the the ADC input is wire to VBUS_IN_Discharge. With this case,

Please kindly take a look the hardware and firmware on your end and make sure it is match.

And then, If the VBUS_IN_Discharge is wire to VBUS node of Type-C interface. Below API can be reference.

/**

* @brief Measure the current voltage on the VBus supply.

* @param port PD port to be measured.

* @return VBus voltage in mV units.

*/

uint16_t pd_hal_measure_vbus(uint8_t port);

Best Regards,

Lisa

0 Likes

Thanks Lisa for the distinction. It makes sense. However, I would like to know if the input to the ADC is selectable by us or is this a hidden configuration inside the PA/CLA/PB project.

0 Likes

Hi Lisa,

Here are more info...

I have a PA project (not PB), but hope to be able to temporarily switch the input to the ADC to sample the VBUS_IN_DISCHARGE voltage. I can point the ADC input back to VBUS_C_MON_DISCHARGE after the initial sample.

I was playing with the input to the ADC. By default, pd_hal_measure_vbus_in is getting sample:

PD_ADC_INPUT_AMUX_B using PD_ADC_ID_0

I tried writing my own function to read:

PD_ADC_INPUT_AMUX_A using PD_ADC_ID_0 but with partial success. Perhaps my AMUX select is not selecting VBUS exactly. It seems to be selecting an internal node. How do I configure AMUX_A/AMUX_B to temporarily sample VBUS_IN_DISCHARGE?

Thanks in advance,

Jonathan

0 Likes

Hi Jonathan,

Your understand is correct. You could refer below example to read voltage on VBUS_IN_DISCHARGE node.

uint16_t VBUS_IN_measure (uint8_t port)

{

    /* Sample the VCC voltage using ADC. */

    uint8_t level;

    uint16_t retval;

//  Use VBUS_IN monitor VBUS

    PPDSS_REGS_T pd = gl_pdss[port];

    pd->amux_nhv_ctrl |= ((1 << AMUX_ADC_CCG3PA_VBUS_IN_8P_EN_POS) |

    (1 << AMUX_ADC_CCG3PA_VBUS_IN_20P_EN_POS));   

    CyDelayUs(10);   

   

    level = pd_adc_sample(port, APP_VBUS_POLL_ADC_ID, APP_VBUS_POLL_ADC_INPUT);

    retval = pd_adc_get_vbus_voltage(port, APP_VBUS_POLL_ADC_ID, level);

//  Revise back to VBUS_C

    pd->amux_nhv_ctrl &= ~((1 << AMUX_ADC_CCG3PA_VBUS_IN_8P_EN_POS) |

    (1 << AMUX_ADC_CCG3PA_VBUS_IN_20P_EN_POS));

    CyDelayUs(10);

   

    return retval;

}

Best Regards,

Lisa

0 Likes