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

    Visitor II
    May 2, 2023

    Any help? @HFISTM​ 

    ST Employee
    May 5, 2023

    Hello @FelipeFRL​ ,

    Thanks, I've understood the issue.

    Could you please try the following fix ?

    Please replace line 427 to 439 (the whole block if (((srcminvoltage100mv <= snkmaxvolta ...) by:

     /* Match if SNK APDO voltage overlaps with the SRC APDO voltage range */
     if (((srcminvoltage100mv <= snkmaxvoltage100mv) && (srcminvoltage100mv >= snkminvoltage100mv)) ||
     ((snkminvoltage100mv <= srcmaxvoltage100mv) && (snkminvoltage100mv >= srcminvoltage100mv)))
     {
     if (snkmaxcurrent50ma <= srcmaxcurrent50ma)
     {
     if (0U != *PtrRequestedPower)
     {
     /* A specific voltage was requested, verify it */
     if ((PWR_DECODE_100MV(snkminvoltage100mv) <= (*PtrRequestedVoltage)) && 
     ((*PtrRequestedVoltage) <= PWR_DECODE_100MV(snkmaxvoltage100mv)))
     {
     currentrequestedpower = (*PtrRequestedVoltage * PWR_DECODE_50MA(snkmaxcurrent50ma))
     / 1000U; /* mW */
     currentrequestedvoltage = (*PtrRequestedVoltage / 50U);
     }
     }
     else
     {
     /* No specific voltage was requested, take the maximum possible voltage:
     min between the source max and Sink max */
     *PtrRequestedVoltage = MIN(PWR_DECODE_100MV(srcmaxvoltage100mv),
     PWR_DECODE_100MV(snkmaxvoltage100mv));
     
     currentrequestedpower = (*PtrRequestedVoltage * PWR_DECODE_50MA(snkmaxcurrent50ma))
     / 1000U; /* mW */
     currentrequestedvoltage = (*PtrRequestedVoltage / 50U); 
     }
     }
     }

    Thank you for your feedback regarding this bug, we will update the x-cube-tcpp package to fix it shortly.

    Best regards

    Visitor II
    May 5, 2023

    Thanks for the response!!

    It didn't work, I can't even request the PDOs now. I made a sketchy but honest solution, but it can't be passed to the tcpp example as it won't work with other Source devices. It seems like your solution is way smarter and the right one to be passed to the tcpp example, it just needs to work.

    ST Employee
    May 10, 2023

    Hello @FelipeFRL​ ,

    Please try with the original code from x-cube-tcpp without any modifications but the one in this thread. (USBPD_DPM_RequestMessageRequest modification + the code I just sent above).

    It worked on our side so ensuring that we are aligned on the same code would help.

    Thanks

    Visitor II
    May 31, 2023

    It seems to have worked, that fixed the original problem, but I have other problems now. It won't finalize the request made even though it has recognized the request correctly. Every subsequent request I make (even get_status, or requestHardReset), it gets status USBPD_BUSY and then traces REQUEST not accepted by the stack.

    Any clue?