Skip to main content
Visitor II
November 10, 2022
Solved

Message Rejected for this Port Configuration on the STM32 x-cube-tcpp example

  • November 10, 2022
  • 15 replies
  • 7881 views

Good afternoon together

I got myself a Nucleo with the STM32G474RE and a shield X-NUCLEO-SNK1M1 to develop a USB-C PD interface (sink), now I cloned the example from Github, built and downloaded it. The cable and the power plug are recognised, but if I select a specific PDO, I get the following message "Message Rejected from this Port Configuration" (see picture). And no PDO is selected. How should I configure the port, if this is not already set in the example?

    This topic has been closed for replies.
    Best answer by HFISTM

    Hello @nikolai2111​ ,

    Thank you for the details, I understand your problem.

    In your case if you look at the very end of the trace where the message is rejected, you will see "ADVICE: update USBPD_DPM_RequestMessageRequest", which means that you are trying to use a function which is not implemented yet on this simple example. This is user code that you can make according to your needs.

    If you search for the actual USBPD_DPM_RequestMessageRequest function, you will find a short explanation on what you could do with your implementation.

    As a quick example to just make what you were trying to do on STM32CubeMonitorUCPD work, you can try this code:

    USBPD_StatusTypeDef USBPD_DPM_RequestMessageRequest(uint8_t PortNum, uint8_t IndexSrcPDO, uint16_t RequestedVoltage)
    {
     USBPD_StatusTypeDef _status = USBPD_ERROR;
    /* USER CODE BEGIN USBPD_DPM_RequestMessageRequest */
     uint32_t voltage, allowablepower;
     USBPD_SNKRDO_TypeDef rdo;
     USBPD_PDO_TypeDef pdo;
     USBPD_CORE_PDO_Type_TypeDef pdo_object;
     USBPD_USER_SettingsTypeDef *puser = (USBPD_USER_SettingsTypeDef *)&DPM_USER_Settings[PortNum];
     USBPD_DPM_SNKPowerRequestDetailsTypeDef request_details;
     rdo.d32 = 0;
     
     /* selected SRC PDO */
     pdo.d32 = DPM_Ports[PortNum].DPM_ListOfRcvSRCPDO[(IndexSrcPDO - 1)];
     voltage = RequestedVoltage;
     allowablepower = (puser->DPM_SNKRequestedPower.MaxOperatingCurrentInmAunits * RequestedVoltage) / 1000U;
     
     if (USBPD_TRUE == USER_SERV_SNK_EvaluateMatchWithSRCPDO(PortNum, pdo.d32, &voltage, &allowablepower))
     {
     /* Check that voltage has been correctly selected */
     if (RequestedVoltage == voltage)
     {
     request_details.RequestedVoltageInmVunits = RequestedVoltage;
     request_details.OperatingCurrentInmAunits = (1000U * allowablepower)/RequestedVoltage;
     request_details.MaxOperatingCurrentInmAunits = puser->DPM_SNKRequestedPower.MaxOperatingCurrentInmAunits;
     request_details.MaxOperatingPowerInmWunits = puser->DPM_SNKRequestedPower.MaxOperatingPowerInmWunits;
     request_details.OperatingPowerInmWunits = puser->DPM_SNKRequestedPower.OperatingPowerInmWunits;
     
     USER_SERV_SNK_BuildRDOfromSelectedPDO(PortNum, (IndexSrcPDO - 1), &request_details, &rdo, &pdo_object);
     
     _status = USBPD_PE_Send_Request(PortNum, rdo.d32, pdo_object);
     }
     }
    /* USER CODE END USBPD_DPM_RequestMessageRequest */
     DPM_USER_ERROR_TRACE(PortNum, _status, "REQUEST not accepted by the stack");
     return _status;
    }

    Make sure you also export the USER_SERV_SNK_BuildRDOfromSelectedPDO and USER_SERV_SNK_EvaluateMatchWithSRCPDO functions in usbpd_user_services.h (meaning removing "static"), as you will now be calling them from a different file.

    As a generic rule, where you find "ADVICE" in the trace is where you should add some code in order to implement the functionalities you need.

    Hope this solves your problem,

    Best regards

    15 replies

    ST Employee
    November 10, 2022

    Hello @nikolai2111​ 

    You are seeing this message because your sink PDO doesn't match the Src PDOs. You will have to change the sink PDO in the application by changing them in cubeMX or directly in file usbpd_pdo_def.h.

    What are your SRC PDO ? Could you share the trace ?

    Please have a look at the wiki for trace & PDO description : WIKI

    Best regards.

    Visitor II
    November 10, 2022

    Thank you for your quick reply!

    Sorry, the images were not uploaded/attached. However, I have manually adjusted them to the PDO of the source via the UCPD Monitor / Port Configuration / Sink Capabilities.

     0693W00000WI2D6QAL.png0693W00000WI2CwQAL.png0693W00000WI2DpQAL.png0693W00000WI2CmQAL.png

    Visitor II
    November 13, 2022

    Now after further investigation I noticed that only after a hard(-ware) reset the correct PDO is selected? Is this how it is supposed to be?

    HFISTMAnswer
    ST Employee
    November 17, 2022

    Hello @nikolai2111​ ,

    Thank you for the details, I understand your problem.

    In your case if you look at the very end of the trace where the message is rejected, you will see "ADVICE: update USBPD_DPM_RequestMessageRequest", which means that you are trying to use a function which is not implemented yet on this simple example. This is user code that you can make according to your needs.

    If you search for the actual USBPD_DPM_RequestMessageRequest function, you will find a short explanation on what you could do with your implementation.

    As a quick example to just make what you were trying to do on STM32CubeMonitorUCPD work, you can try this code:

    USBPD_StatusTypeDef USBPD_DPM_RequestMessageRequest(uint8_t PortNum, uint8_t IndexSrcPDO, uint16_t RequestedVoltage)
    {
     USBPD_StatusTypeDef _status = USBPD_ERROR;
    /* USER CODE BEGIN USBPD_DPM_RequestMessageRequest */
     uint32_t voltage, allowablepower;
     USBPD_SNKRDO_TypeDef rdo;
     USBPD_PDO_TypeDef pdo;
     USBPD_CORE_PDO_Type_TypeDef pdo_object;
     USBPD_USER_SettingsTypeDef *puser = (USBPD_USER_SettingsTypeDef *)&DPM_USER_Settings[PortNum];
     USBPD_DPM_SNKPowerRequestDetailsTypeDef request_details;
     rdo.d32 = 0;
     
     /* selected SRC PDO */
     pdo.d32 = DPM_Ports[PortNum].DPM_ListOfRcvSRCPDO[(IndexSrcPDO - 1)];
     voltage = RequestedVoltage;
     allowablepower = (puser->DPM_SNKRequestedPower.MaxOperatingCurrentInmAunits * RequestedVoltage) / 1000U;
     
     if (USBPD_TRUE == USER_SERV_SNK_EvaluateMatchWithSRCPDO(PortNum, pdo.d32, &voltage, &allowablepower))
     {
     /* Check that voltage has been correctly selected */
     if (RequestedVoltage == voltage)
     {
     request_details.RequestedVoltageInmVunits = RequestedVoltage;
     request_details.OperatingCurrentInmAunits = (1000U * allowablepower)/RequestedVoltage;
     request_details.MaxOperatingCurrentInmAunits = puser->DPM_SNKRequestedPower.MaxOperatingCurrentInmAunits;
     request_details.MaxOperatingPowerInmWunits = puser->DPM_SNKRequestedPower.MaxOperatingPowerInmWunits;
     request_details.OperatingPowerInmWunits = puser->DPM_SNKRequestedPower.OperatingPowerInmWunits;
     
     USER_SERV_SNK_BuildRDOfromSelectedPDO(PortNum, (IndexSrcPDO - 1), &request_details, &rdo, &pdo_object);
     
     _status = USBPD_PE_Send_Request(PortNum, rdo.d32, pdo_object);
     }
     }
    /* USER CODE END USBPD_DPM_RequestMessageRequest */
     DPM_USER_ERROR_TRACE(PortNum, _status, "REQUEST not accepted by the stack");
     return _status;
    }

    Make sure you also export the USER_SERV_SNK_BuildRDOfromSelectedPDO and USER_SERV_SNK_EvaluateMatchWithSRCPDO functions in usbpd_user_services.h (meaning removing "static"), as you will now be calling them from a different file.

    As a generic rule, where you find "ADVICE" in the trace is where you should add some code in order to implement the functionalities you need.

    Hope this solves your problem,

    Best regards

    Visitor II
    November 19, 2022

    Dear @HFISTM​

    Thank you very much!

    I see now that I thought the example was already usable for simple PD tasks and configuration.

    I have not implemented it yet, but will do so in the coming days.

    Best regards

    Visitor II
    April 10, 2023

    I used this code for my G071RBT6 nucleo board with a 4 PDOs power supply (2 fixed and 2 APDOs), and the only PDO that can be requested is the first. Can't even request the one that it initializes with (the highest powered, 4th PDO, 11V@2.25A). I request the PDOs listed in UCPD Monitor but I get "request not accepted by the stack". It seems like the board can't recognize the received PDOs even though I can see them on UCPD Monitor and they're exact to specification. Maybe the PDOs are received by UCPD but ill-defined on the code/STM32CubeMX.

    I already understood from the USB IF specification that the 4 byte value defines the PDO bit by bit.

    I got to request the two APDOs but not quite, as I can only request them with their maximum voltages. Why can't I request them with lower voltages aka inside their operating range?

    And why can't I request the second fixed PDO? It doesn't make sense.

    Can't seem to understand what could be happening. Can someone shed me some light?

    Here are my CubeMX definitions:


    _legacyfs_online_stmicro_images_0693W00000bho2WQAQ.png

    ST Employee
    April 11, 2023

    Hello @FelipeFRL​ ,

    Could you please send your trace ? It will be hard to help without it.

    As I can see from your cube MX screenshot is that you declared that your board would take one of the following power profile:

    • 5V 3A
    • 9V 2.77A
    • APDO 3.3-5.9V 3A
    • APDO 3.3-11V 2.25A

    I assume that these are your maximum source capabilities (It could be seen in the trace). I suspect that you are not able to select a PDO because you request exactly the maximum of your source and the source declines the request.

    Maybe try to lower the requested current to see if that helps. Again, we will need to look at the trace when you ask for a PDO and get the not accepted message to see what's really happening.

    Regards

    Visitor II
    April 11, 2023

    Thanks for the fast reply!

    The thing is, it ONLY accepts the APDOs requests when I request them at maximum voltage, and only then. I can't request them at a lower voltage, like their minimum 3.3V or any other voltage on the operational range.

    Another issue, am I able to measure the current with this hardware (STM32G071RBT6 NUCLEO Board w/ SN1M1 Expansion Board) or do I need an external IC to sense curent with the ADC? If i can without another IC, where can I find the basic code to implement this?

    Anyway, here are my traces and the port communication window in UCPD Monitor. At first it requested the highest powered PDO which is 11V@2.25A, then I requested manually the 5V fixed PDO, then 9V fixed PDO and at last the two APDOs with lower voltage than the maximum and I got "request not accepted by the stack".


    _legacyfs_online_stmicro_images_0693W00000bhrVfQAI.png
    _legacyfs_online_stmicro_images_0693W00000bhrVuQAI.png
    _legacyfs_online_stmicro_images_0693W00000bhrWEQAY.png
    _legacyfs_online_stmicro_images_0693W00000bhrWJQAY.png
    _legacyfs_online_stmicro_images_0693W00000bhrWTQAY.png

    ST Employee
    April 11, 2023

    Thank you for your images but unfortunately there is a lot of the trace missing (source capa for example), could you please share it in .cpd format ? Please refer to this wiki.

    According to the image you shared, each time you requested the power profile the source accepted it. Did it not worked (except from the message you got on ucpd monitor) ?

    You can measure the current drawn on VBUS by completing the BSP_USBPD_PWR_VBUSGetCurrent function

    Regards

    Visitor II
    April 11, 2023

    The traces in .cpd format can be seen at this link.

    Visitor II
    April 11, 2023

    It didn't at the last image, when I requested the 3.3V-5.9V APDO with 3.3V. The last message is "DEBUG 607514 REQUEST not accepted by the stack", which is the response to this last request.

    About the VBUSGetCurrent function, I tried copying the code from VBUSGetVoltage, changing variables and the multiplier but can't seem to make it work as I get false current readings (when comparing with multimeter and with current oscilloscope probe too). Where can I find a code exemple that really works?

    Here are all the traces in text, even though SRC CAPA can be seen coloured at the first image:

     0 CAD 278616 0 USBPD_CAD_STATE_ATTACHED_WAIT

    1 CAD 278740 0 USBPD_CAD_STATE_ATTACHED

    2 NOTIF 278740 0 USBSTACK_START

    3 DEBUG 278740 0 ADVICE: USBPD_DPM_Notification:104

    4 EVENT 278740 0 EVENT_ATTACHED

    5 DEBUG 278740 0 ADVICE: USBPD_DPM_Notification:104

    6 PE 278740 0 PE_SNK_STARTUP

    7 PE 278740 0 PE_SNK_WAIT_FOR_CAPABILITIES

    8 IN 278943 0 SOP PD3 s:018  H:0x41A1  (id:0, DR:DFP, PR:SRC) SRC_CAPABILITIES DATA: 2C91010A15D102003C2176C83721DCC8

    Option: DRDEPW

    [1] Fixed : 5V - 3A /

    [2] Fixed : 9V - 2.77A / 

    [3] Programmable : [3.3V - 5.9V] - 3A / 

    [4] Programmable : [3.3V - 11V] - 2.75A / 

    9 OUT 278943 0 SOP s:002  H:0x0041   (id:0, DR:UFP, PR:SNK) GOODCRC

    10 PE 278944 0 PE_SNK_EVALUATE_CAPABILITY

    11 PE 278946 0 PE_SNK_SEND_REQUEST

    12 OUT 278946 0 SOP PD3 REQUEST s:006  H:0x1082  (id:0, DR:UFP, PR:SNK) DATA: 15550420 / ObjectPosition:2 / GiveBack:0 / CapabilityMismatch:0 / USBCommunicationCapable:0 / NoUSBSuspend:0 / UnchunkedExtendedMessagesSupported:0

    13 IN 278947 0 SOP s:002  H:0x0161   (id:0, DR:DFP, PR:SRC) GOODCRC

    14 PE 278947 0 PE_SNK_SELECT_CAPABILITY

    15 IN 278948 0 SOP PD3 ACCEPT s:002  H:0x03A3   (id:1, DR:DFP, PR:SRC) 

    16 OUT 278948 0 SOP s:002  H:0x0241   (id:1, DR:UFP, PR:SNK) GOODCRC

    17 NOTIF 278948 0 POWER_STATE_CHANGE

    18 DEBUG 278948 0 ADVICE: USBPD_DPM_Notification:90

    19 NOTIF 278949 0 REQUEST_ACCEPTED

    20 PE 278949 0 PE_SNK_TRANSITION_SNK

    21 IN 279235 0 SOP PD3 PS_RDY s:002  H:0x05A6   (id:2, DR:DFP, PR:SRC) 

    22 OUT 279235 0 SOP s:002  H:0x0441   (id:2, DR:UFP, PR:SNK) GOODCRC

    23 NOTIF 279236 0 POWER_STATE_CHANGE

    24 DEBUG 279236 0 ADVICE: USBPD_DPM_Notification:90

    25 NOTIF 279236 0 POWER_EXPLICIT_CONTRACT

    26 DEBUG 279236 0 ADVICE: USBPD_DPM_Notification:16

    27 PE 279236 0 PE_STATE_READY

    28 NOTIF 279236 0 STATE_SNK_READY

    29 DEBUG 279236 0 ADVICE: USBPD_DPM_Notification:32

    30 PE 279236 0 PE_STATE_READY_WAIT

    31 PE 287267 0 PE_SNK_SEND_REQUEST

    32 OUT 287267 0 SOP PD3 REQUEST s:006  H:0x1282  (id:1, DR:UFP, PR:SNK) DATA: 2CB10410 / ObjectPosition:1 / GiveBack:0 / CapabilityMismatch:0 / USBCommunicationCapable:0 / NoUSBSuspend:0 / UnchunkedExtendedMessagesSupported:0

    33 IN 287269 0 SOP s:002  H:0x0361   (id:1, DR:DFP, PR:SRC) GOODCRC

    34 PE 287269 0 PE_SNK_SELECT_CAPABILITY

    35 IN 287269 0 SOP PD3 ACCEPT s:002  H:0x07A3   (id:3, DR:DFP, PR:SRC) 

    36 OUT 287269 0 SOP s:002  H:0x0641   (id:3, DR:UFP, PR:SNK) GOODCRC

    37 NOTIF 287270 0 POWER_STATE_CHANGE

    38 DEBUG 287270 0 ADVICE: USBPD_DPM_Notification:90

    39 NOTIF 287270 0 REQUEST_ACCEPTED

    40 PE 287270 0 PE_SNK_TRANSITION_SNK

    41 IN 287556 0 SOP PD3 PS_RDY s:002  H:0x09A6   (id:4, DR:DFP, PR:SRC) 

    42 OUT 287556 0 SOP s:002  H:0x0841   (id:4, DR:UFP, PR:SNK) GOODCRC

    43 NOTIF 287556 0 POWER_STATE_CHANGE

    44 DEBUG 287557 0 ADVICE: USBPD_DPM_Notification:90

    45 NOTIF 287557 0 POWER_EXPLICIT_CONTRACT

    46 DEBUG 287557 0 ADVICE: USBPD_DPM_Notification:16

    47 PE 287557 0 PE_STATE_READY

    48 NOTIF 287557 0 STATE_SNK_READY

    49 DEBUG 287557 0 ADVICE: USBPD_DPM_Notification:32

    50 PE 287557 0 PE_STATE_READY_WAIT

    51 PE 294467 0 PE_SNK_SEND_REQUEST

    52 OUT 294467 0 SOP PD3 REQUEST s:006  H:0x1482  (id:2, DR:UFP, PR:SNK) DATA: 15550420 / ObjectPosition:2 / GiveBack:0 / CapabilityMismatch:0 / USBCommunicationCapable:0 / NoUSBSuspend:0 / UnchunkedExtendedMessagesSupported:0

    53 IN 294469 0 SOP s:002  H:0x0561   (id:2, DR:DFP, PR:SRC) GOODCRC

    54 PE 294469 0 PE_SNK_SELECT_CAPABILITY

    55 IN 294469 0 SOP PD3 ACCEPT s:002  H:0x0BA3   (id:5, DR:DFP, PR:SRC) 

    56 OUT 294469 0 SOP s:002  H:0x0A41   (id:5, DR:UFP, PR:SNK) GOODCRC

    57 NOTIF 294470 0 POWER_STATE_CHANGE

    58 DEBUG 294470 0 ADVICE: USBPD_DPM_Notification:90

    59 NOTIF 294470 0 REQUEST_ACCEPTED

    60 PE 294470 0 PE_SNK_TRANSITION_SNK

    61 IN 294756 0 SOP PD3 PS_RDY s:002  H:0x0DA6   (id:6, DR:DFP, PR:SRC) 

    62 OUT 294756 0 SOP s:002  H:0x0C41   (id:6, DR:UFP, PR:SNK) GOODCRC

    63 NOTIF 294756 0 POWER_STATE_CHANGE

    64 DEBUG 294756 0 ADVICE: USBPD_DPM_Notification:90

    65 NOTIF 294756 0 POWER_EXPLICIT_CONTRACT

    66 DEBUG 294757 0 ADVICE: USBPD_DPM_Notification:16

    67 PE 294757 0 PE_STATE_READY

    68 NOTIF 294757 0 STATE_SNK_READY

    69 DEBUG 294757 0 ADVICE: USBPD_DPM_Notification:32

    70 PE 294757 0 PE_STATE_READY_WAIT

    71 DEBUG 298422 0 REQUEST not accepted by the stack

    72 DEBUG 306386 0 REQUEST not accepted by the stack

    73 PE 601467 0 PE_SNK_SEND_REQUEST

    74 OUT 601467 0 SOP PD3 REQUEST s:006  H:0x1682  (id:3, DR:UFP, PR:SNK) DATA: 2CB10410 / ObjectPosition:1 / GiveBack:0 / CapabilityMismatch:0 / USBCommunicationCapable:0 / NoUSBSuspend:0 / UnchunkedExtendedMessagesSupported:0

    75 IN 601468 0 SOP s:002  H:0x0761   (id:3, DR:DFP, PR:SRC) GOODCRC

    76 PE 601468 0 PE_SNK_SELECT_CAPABILITY

    77 IN 601469 0 SOP PD3 ACCEPT s:002  H:0x0FA3   (id:7, DR:DFP, PR:SRC) 

    78 OUT 601469 0 SOP s:002  H:0x0E41   (id:7, DR:UFP, PR:SNK) GOODCRC

    79 NOTIF 601469 0 POWER_STATE_CHANGE

    80 DEBUG 601469 0 ADVICE: USBPD_DPM_Notification:90

    81 NOTIF 601469 0 REQUEST_ACCEPTED

    82 PE 601469 0 PE_SNK_TRANSITION_SNK

    83 IN 601756 0 SOP PD3 PS_RDY s:002  H:0x01A6   (id:0, DR:DFP, PR:SRC) 

    84 OUT 601756 0 SOP s:002  H:0x0041   (id:0, DR:UFP, PR:SNK) GOODCRC

    85 NOTIF 601757 0 POWER_STATE_CHANGE

    86 DEBUG 601757 0 ADVICE: USBPD_DPM_Notification:90

    87 NOTIF 601757 0 POWER_EXPLICIT_CONTRACT

    88 DEBUG 601757 0 ADVICE: USBPD_DPM_Notification:16

    89 PE 601757 0 PE_STATE_READY

    90 NOTIF 601757 0 STATE_SNK_READY

    91 DEBUG 601757 0 ADVICE: USBPD_DPM_Notification:32

    92 PE 601757 0 PE_STATE_READY_WAIT

    93 DEBUG 607514 0 REQUEST not accepted by the stack

    Regards,

    Felipe

    Graduate II
    May 16, 2024

    Its not relevant yet for you but I hope someone will find this answer useful. The VBUS_Get_Current() function example can be found in CubeMX examples for G0 boards: STM32G081B-EVAL. You need to open the DemoUCPD project in CubeIDE, for me the path is:

    C:\ST\STM32CubeMX\Repository\STM32Cube_FW_G0_V1.6.2\Projects\STM32G081B-EVAL\Demonstrations\DemoUCPD

    Now in DemoUCPD\Src\demo_application.c you can find the BSP_USBPD_PWR_VBUSGetCurrent() call which can lead you to the example when looking for its declaration.

    /**
     * @brief Get actual current level measured on the VBUS line.
     * @PAram Instance Type-C port identifier
     * This parameter can be take one of the following values:
     * @arg @ref USBPD_PWR_TYPE_C_PORT_1
     * @arg @ref USBPD_PWR_TYPE_C_PORT_2
     * @PAram pCurrent Pointer on measured current level (in mA)
     * @retval BSP status
     */
    int32_t BSP_USBPD_PWR_VBUSGetCurrent(uint32_t Instance, int32_t *pCurrent)
    {
     /* USER CODE BEGIN BSP_USBPD_PWR_VBUSGetCurrent */
     /* Check if instance is valid */
     int32_t ret = BSP_ERROR_NONE;
    
     if ((Instance >= USBPD_PWR_INSTANCES_NBR) || (NULL == pCurrent))
     {
     ret = BSP_ERROR_WRONG_PARAM;
     }
     else
     {
     int32_t current = 0;
    
     if (Instance == USBPD_PWR_TYPE_C_PORT_1)
     {
     current = PWR_ConvertADCDataToCurrent(aADCxConvertedValues[2u]);
     }
     else
     {
     if (Instance == USBPD_PWR_TYPE_C_PORT_2)
     {
     current = PWR_ConvertADCDataToCurrent(aADCxConvertedValues[3u]);
     }
     }
    
     *pCurrent = current;
     }
     return ret;
     /* USER CODE END BSP_USBPD_PWR_VBUSGetCurrent */
    /**
     * @brief Calculate the VBUS current level corresponding to ADC raw converted data.
     * @note Current level is measured though INA199x1 output voltage level.
     * @note INA199x1 measures currents through a resistive shunt (0.005 Ohms) in
     * two directions.
     * @note VDD corresponds to the zero-input level state. The Vout responds
     * by increasing above VDD for positive differential signals (relative
     * to the IN� pin) and responds by decreasing below VDD for negative
     * differential signals.
     *
     * VBUS -----. Rs .-....
     * | | .------------.
     * | | | INA199x1 |
     * | | | |
     * | '--> IN+ > Vout (GAIN * Vs)
     * | Vs ^ | | 0 <= Vout < VDD - negative current
     * | | | | Vout = VDD - zero-input
     * '-------> IN- | Vout > VDD - positive current
     * | |
     * Vref > |
     * (Vdd/2) | |
     * '------------'
     *
     * Is = Vout/(GAIN * Rs) = (Vout - 2*Vref)/(Gain * Rs)
     * where Vout = ADCData * (VDD/ADC_FULL_SCALE)
     * Is = (ADCData * Vdd)/(ADC_FULL_SCALE * Gain * Rs) - Vdd/(Gain * Rs)
     * Vdd = 3300 mV, ADC_FULL_SCALE = 4095, Gain = 50, Rs = 5/1000
     * @PAram ADCData ADC raw converted data (resolution 12 bits)
     * @retval VBUS analog current (unit: mA)
     */
    static int32_t PWR_ConvertADCDataToCurrent(uint32_t ADCData)
    {
     int32_t current;
    
     current = ((ADCData * VDD) >> 10u) - 6600u;
    
     return current;
    }

    Note that the Current measurement on STM32G081B-EVAL is provided by UCPD daughterboard USB PD and its INA199C1DCKR (see Figure 50. in UM2403).

    Isense measurement is also native for TCPP02 and TCPP03 with using small R (as in Figure 14. of UM2891), but not for TCPP01 (which is on SNK1M1).

    Untitled.png

    Visitor II
    April 12, 2023

    Dear @HFISTM​ ,

    I'm debbuging the hell out of this aplication, and the problem seems to be within line 432 of usbpd_user_services.c file. The USER_SERV_SNK_EvaluateMatchWithSRCPDO function passes only the max possible voltage to the RequestedVoltage variable used in ResquestMessageRequest function, then causing its if condition of equality between voltage and RequestedVoltage to be False, which then traces the Debug message "REQUEST not accepted by the stack". I just don't know what value to use on line 432 for it to proceed in the right way.

    After commenting out this line, the application seems to be out of control, as it won't establish a contract. The hardware it keeps unstoppably requesting for the APDO to be instated, rejecting the request and then resetting, over and over.

    Here you can see one iteration of this unending cycle of madness:


    _legacyfs_online_stmicro_images_0693W00000bi1qjQAA.png 

    Regards,

    Felipe