Skip to main content
NApps.1
Associate II
Sep 17, 2021 11:26 AM UTC
Question

I am currently using a STM32G081b eval board with a STM32G474QE MCU I am using the demoucpd example code if i plug in display for my laptop it works over usb c but doesn't on mobiles device does anyone know why?

..

This topic has been closed for replies.

22 replies

TDK
Sep 17, 2021 12:04 PM UTC

> I am currently using a STM32G081b eval board with a STM32G474QE MCU

Doesn't that board have a STM32G081RBT6 chip?

USB-PD is messy. It needs to request the correct voltages, it might be requesting something else. Perhaps look at differences in what the displays need.

"If you feel a post has answered your question, please click ""Accept as Solution""."
NApps.1
NApps.1Author
Associate II
Sep 20, 2021 7:59 AM UTC

Yes it does have a STM32G081RBT6 chip and the USB-PD side looks correct I have created my own profiles for the voltage which works fine. Using my MacBook pro and hp laptop I can get power, display yet when I try tablets its only provides power I have seen from a STM32 demo video that you can get display out of mobile devices/tablets.

Yohann M.
ST Employee
Sep 22, 2021 6:23 AM UTC

Dear @NA.1067pps​ 

Further information regarding the DP scenario is available in the wiki page.

To understand your issue, you could generate a .cpd trace (Specific tools section).

Regards,

Yohann

NApps.1
NApps.1Author
Associate II
Sep 22, 2021 9:01 AM UTC

This is the log I get when I plug in an ipad just gives me charge no display

NApps.1
NApps.1Author
Associate II
Sep 27, 2021 3:43 PM UTC

I believe I may have found my problem I am trying to run one usb c port to do power and display. Does your library only allow a usb c port to be ether power or display?

I found in your usbpd_def.h some externs do this relate to default values found in the library file if so how can I change this as if I remove the #define __USBPD_DPM_CORE_C it just gives me a load of errors?

Yohann M.
ST Employee
Sep 27, 2021 4:17 PM UTC

No you could configure both port to do power and display... After the limitation is on HW side.

Description of our application is described in USB Power Delivery overview - stm32mcu.

'usbpd_def.h' is the definition file for USB-PD stack library... There are no relations with the Display port configuration which is done in usbpd_vdm_user.c file.

Externs are defined in usbpd_dpm_conf.h file and have a link the user code (usbpd_dpm_core.c) and then __USBPD_DPM_CORE_C is defined in the file.

Yohann

NApps.1
NApps.1Author
Associate II
Sep 27, 2021 4:26 PM UTC

So I am currently have the mind set the device needs to be a DRP to do power and display. Can I just set it up to be a Source ie provide power to say laptop/tablet and also do the display side of things?

Yohann M.
ST Employee
Sep 27, 2021 6:18 PM UTC

yes it is possible... You can request a data role swap to switch your data role if needed (to be in Source + Device mode).

Please refer to Managing USB power delivery systems with STM32 microcontrollers - User manual §4.4.1.

A DPM function is available: USBPD_DPM_RequestDataRoleSwap.

NApps.1
NApps.1Author
Associate II
Sep 27, 2021 6:51 PM UTC

Where would be the best place to request the Data Role Swap? Would it be in USBPD_DPM_Notification same as power role swap recommended here.

Yohann M.
ST Employee
Sep 28, 2021 6:28 AM UTC

Right it is the same suggestion:

/**
 * @brief Callback function called by PE to inform DPM about PE event.
 * @param PortNum The current port number
 * @param EventVal @ref USBPD_NotifyEventValue_TypeDef
 * @retval None
 */
void USBPD_DPM_Notification(uint8_t PortNum, USBPD_NotifyEventValue_TypeDef EventVal)
{
/* USER CODE BEGIN USBPD_DPM_Notification */
 switch(EventVal)
 {
 case USBPD_NOTIFY_STATE_SRC_READY:
 {
 /* Check that the current data role is not already in UFP (device) */
 if (USBPD_PORTDATAROLE_DFP == DPM_Params[PortNum].PE_DataRole)
 { 
 if (USBPD_DPM_RequestDataRoleSwap(PortNum) != USBPD_OK)
 {
 /* Stack is BUSY... Suggest to postpone the request in using a timer
 to delay this request... Refer to DPM_TimerSRCExtendedCapa usage in 
 EVAL Demonstration */
 DPM_START_TIMER(PortNum, DPM_TimerRetryDRS, 100);
 }
 }
 break;
 default :
 break;
 }
/* USER CODE END USBPD_DPM_Notification */
}

Usage timer in DPM can be found HERE...

Yohann