2020-08-26 03:01 AM
Hi STteam,
my name is Himavanth, working as an Embedded Engineer at Supralax Electronics Pvt.Ltd. please have a look at the problem.
@brief : We are working PD source solution(i.e. 60Watt (20V @ 3A max)) using STM32G081RBT6. We are taking USB-PD_Provider_1port as an Base reference project.
@Reference : I have gone through each and every line of UM2552 reference manual I found really good information to setup the USBPD stack.
@context:
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file usbpd_pdo_defs.h
* @author MCD Application Team
* @brief Header file for definition of PDO/APDO values for 2 ports(DRP/SNK) configuration
******************************************************************************
*
* Copyright (c) 2018 STMicroelectronics. All rights reserved.
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
#ifndef __USBPD_PDO_DEF_H_
#define __USBPD_PDO_DEF_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Define ------------------------------------------------------------------*/
/* USER CODE BEGIN Define */
/* USER CODE END Define */
/* Exported typedef ----------------------------------------------------------*/
/* USER CODE BEGIN typedef */
/**
* @brief USBPD Port PDO Structure definition
*
*/
/* USER CODE END typedef */
/* Exported define -----------------------------------------------------------*/
/* USER CODE BEGIN Exported_Define */
#define USBPD_CORE_PDO_SRC_FIXED_MAX_CURRENT 3
#define USBPD_CORE_PDO_SNK_FIXED_MAX_CURRENT 1500
/* USER CODE END Exported_Define */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN constants */
/* USER CODE END constants */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN macro */
/* USER CODE END macro */
/* Exported variables --------------------------------------------------------*/
/* USER CODE BEGIN variables */
/* USER CODE END variables */
#ifndef __USBPD_PWR_IF_C
extern const uint32_t PORT0_PDO_ListSRC[USBPD_MAX_NB_PDO];
extern const uint32_t PORT0_PDO_ListSNK[USBPD_MAX_NB_PDO];
extern const uint32_t PORT1_PDO_ListSRC[USBPD_MAX_NB_PDO];
extern const uint32_t PORT1_PDO_ListSNK[USBPD_MAX_NB_PDO];
#else
/* Definition of Source PDO for Port 0 */
const uint32_t PORT0_PDO_ListSRC[USBPD_MAX_NB_PDO] =
{
/* PDO 1 */
(0x0201912CU),
/* PDO 2 */
(0x00000000U),
/* PDO 3 */
(0x00000000U),
/* PDO 4 */
(0x00000000U),
/* PDO 5 */
(0x00000000U),
/* PDO 6 */
(0x00000000U),
/* PDO 7 */
(0x00000000U)
};
/* Definition of Sink PDO for Port 0 */
const uint32_t PORT0_PDO_ListSNK[USBPD_MAX_NB_PDO] =
{
/* PDO 1 */
(0x00000000U),
/* PDO 2 */
(0x00000000U),
/* PDO 3 */
(0x00000000U),
/* PDO 4 */
(0x00000000U),
/* PDO 5 */
(0x00000000U),
/* PDO 6 */
(0x00000000U),
/* PDO 7 */
(0x00000000U)
};
#endif
/* Exported functions --------------------------------------------------------*/
/* USER CODE BEGIN functions */
/* USER CODE END functions */
#ifdef __cplusplus
}
#endif
#endif /* __USBPD_PDO_DEF_H_ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
@Quetions :
Note : I couldn't initialize the PDO's as stated in UM2552 page No. 21
Thanks & Regards
Himavanth
Solved! Go to Solution.
2020-09-08 03:39 AM
Hi Yohann,
I've done with changes to ADC setting and started ADC conversion.
I found Voltage is constant(i.e. 22968) throughout the operation and it's independent of the VBUS Voltage. after I digging deep more I found aADCxConvertedValues[1] is constant throughout the operation and is 4095(equal to full scale value, which shouldn't be 4095).
uint32_t BSP_PWR_VBUSGetVoltage(uint32_t PortId)
{
/* USER CODE BEGIN BSP_PWR_VBUSGetVoltage */
uint32_t voltage = 0;
if (PortId == TYPE_C_PORT_1)
{
voltage = PWR_ConvertADCDataToVoltage(aADCxConvertedValues[1]);
}
else if (PortId == TYPE_C_PORT_2)
{
voltage = PWR_ConvertADCDataToVoltage(aADCxConvertedValues[0]);
}
return voltage;
/* USER CODE END BSP_PWR_VBUSGetVoltage */
}
After this I've gone through code related to ADC, I couldn't fine anything suspicious. seems to be problem with ADC reading help me out to get out of the issue.
Thanks & regards
2020-09-09 02:12 AM
Dear Himavanth
you configured only 2 channels in your code (VBUS1 on ADC_CHANNEL_9 then rank 0 of PWR_ConvertADCDataToVoltage and VBUS2 on ADC_CHANNEL_3 on rank2) but you still define a table of 4 elements in aADCxConvertedValues) Could you try to set the size of table at 2? When you start DMA with 2 values only.
#define ADC_NUMBER_CHANNEL 2
/* Variable containing ADC conversions results
aADCxConvertedValues[0]: VSENSE_1
aADCxConvertedValues[1]: VSENSE_2
*/
static __IO uint16_t aADCxConvertedValues[ADC_NUMBER_CHANNEL] = {0};
/**
* @brief Start I/V sense on both Type-C ports.
* @retval 0 success else fail
*/
static uint8_t PWR_StartVBusSensing(void)
{
uint8_t ret = 0;
/* Start ADCx conversions */
if (HAL_ADC_Start_DMA(&hadc1, (uint32_t *)aADCxConvertedValues, ADC_NUMBER_CHANNEL) != HAL_OK) ret++;
return ret;
}
Yohann
2020-09-09 07:34 AM
Hi Yohann,
I am able to get 15V across VBUS after I connect my Disco board to Source device, but the ADC reading value is 16125mV. I found ADC reading Error while reading High voltages(i.e. greater than 10V).
please have a look at the fallowing USBPD log:
After some period of time(typically 10S) PD is Resetting automatically. I suspect that is because of ADC Error only, please suggest some changes to us so that we can get better accuracy.
Note : after 10 seconds BSP_PWR_VBUSOff() automatically getting called.
I have couple of questions for you, please don't hesitate to answer this.
Thanks & Regards
-himavanth
2020-09-09 08:28 AM
1- what is the VBUS voltage without cable connection(or before cable connection)?
VBUS should be at 0V of course... SRC path should be disabled.
2- I am connected Vref+ to VDDA. if I use Vref+ externally, is that going to be reduce my ADC Error?
Internal VREF should be enough for the VBUS measurement. Voltage divider is it correct? What the resistors you put on your board (RA/RB)?
For your test, you can keep the SRC PDO set to 5V and check that you are able to measure correctly 5V on your ADC channel.
In the attached screenshot you put, I don't have a success of the negociation. SRC did not sent a PS_RDY, there is a detach before.
Question: did you change the content of the function 'USBPD_PWR_IF_SetProfile'. Do you set correctly the VBUS value? The code I have is the default the 1st PDO set to 5V.
Note: instead of doing a copy of our cubeMX, you can deliver a file automatically saved on your laptop (.cpd file) under c:\Users\your_login\AppData\Local\Temp\STM32CubeMonitor-UCPD\Acquisition\. (https://wiki.st.com/stm32mcu/wiki/USB_Power_Delivery_overview#Specific_tools)
2020-09-09 09:08 AM
After changes to RA (RA 36000)and RB (RB 6040)values I can able read the some what accurate value. i.e. 15V VBUS as 14908mV. seems to be allowable.
Even after this setting USBPD control getting to BSP_PWR_VBUSOff() each time after Power profile setting.
I didn't made any changes to USBPD_PWR_IF_SetProfile.
still the SRC did not sent a PS_RDY, there is a detach before.
Thank you
2020-10-03 08:40 AM
Hello,
im trying hard to run the USB PD feature on the STM32L552CCT6 controller.
So i rebuild the USB-PD_Consumer_1port example for the STM32L5 to my controller.
All is the same, but when im trying to start and debug the program, the controller stucks after the initalization.
I figured out that the last called function is the USBPD_TRACE_Init(); in the usbpd_dpm_core.c file.
After that the debugger lost the connection to the target and the program stucks. I have to erase the full chip to get the connection again.
I have really no idea whats going on.
So my question is: Does anybody have an idea where the problem is?
Thanks!
2020-10-04 10:37 PM
Hello
Could you please create a new thread for your question?
Thanks
Yohann