2019-07-28 07:33 PM
Dear members,
This is actually a follow up question to my last one STM32G071 UCPD library bug or my problem, but instead of digging deeper and deeper to an already well answered question, and probably out of topic too, I guess I better start a new one.
Solved! Go to Solution.
2019-08-01 01:48 AM
One important, i suppose your code is correct but anyway I prefer check
File : stm32g0xx_it.c the function shall be like below
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
extern void USBPD_DPM_TimerCounter(void);
USBPD_DPM_TimerCounter();
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
osSystickHandler();
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
What is the timebase source ? Can you check your timers ?
2019-07-31 01:13 AM
Hi John
Question 1 : yes this is an error in our documentation, see below the right MSC
Question 2 : the trace is really strange because you started the MSC of power negotiation however the SINK is still sending REQUEST which is broken the MSC sequence and it is why NOTIFY_POWER_STATE_CHANGE and USBPD_PE_RequestSetupNewPower call never happen
Please could you send me the trace file ? it must be available inside this folder c:\Users\user_name\AppData\Local\Temp\STM32CubeMonitor-UCPD\Acquisition\2019_07_29_15_41_57_USBCPD_Debug_File.cpd
Question 3 : I don't understand the issue it is like PE is no more running or an issue with our internal timer. please could you send me the trace i will check deeper ?
The sink behavior is really strange, please could you share what is the material used as sink ?
BR
Dominique
2019-07-31 01:39 AM
Hi John,
Please could you check if the callback has been well initialized ?
inside the function USBPD_DPM_InitCore, check if dpmCallbacks.USBPD_PE_HardReset is not null, value must be equal USBPD_DPM_HardReset
BR
Dominique
2019-07-31 03:26 AM
I am quite sure it is USBPD_DPM_HardReset, because USBPD_DPM_HardReset is called with Status==2 as printed in debug trace right after OUT/HRST trace.
2019-08-01 01:48 AM
One important, i suppose your code is correct but anyway I prefer check
File : stm32g0xx_it.c the function shall be like below
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
extern void USBPD_DPM_TimerCounter(void);
USBPD_DPM_TimerCounter();
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
osSystickHandler();
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
What is the timebase source ? Can you check your timers ?
2019-08-01 04:33 AM
Yes I confirmed that adding USBPD_DPM_TimerCounter(); into my timer base resolved both my problem 2 and 3, SetupNewPower(), PS_RDY, also correct hard reset behaviour can now be observed, big thanks to Dominique and Nicolas for all your kind help!
And I must point out that neither USBPD_DPM_TimerCounter(), USBPD_DMA_PORT0_IRQHandler(), and also USBPD_DMA_PORT0_IRQHandler() is auto-generated from STM32CubeMX nor they are mentioned in UM2552 (unless I missed it, but I did a text search in the PDF and found nothing), so it is easy to be missed unless someone is reading the example source code very carefully, just a suggestion but I guess this can be improved easily?
2019-11-08 02:53 AM
Hi,
In my case I had to call the USBPD_DPM_TimerCounter() and osSystickHandler() function from HAL_TIM_PeriodElapsedCallback():
/**
* @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM2 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
* a global variable "uwTick" used as application time base.
* @param htim : TIM handle
* @retval None
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
if (htim->Instance == TIM2) {
USBPD_DPM_TimerCounter();
}
/* USER CODE END Callback 0 */
if (htim->Instance == TIM2) {
HAL_IncTick();
}
/* USER CODE BEGIN Callback 1 */
if (htim->Instance == TIM2) {
osSystickHandler();
}
/* USER CODE END Callback 1 */
}
I completely agree with @JChau, it is really difficult to figure out what steps are necessary to make the USBPD stack work after generating the code with STM32CubeMX (I used version 5.4.0). I couldn't find anything about that in the software manual UM2552, and also the source documentation is not really helpful. E.g. these comments don't point out that I have to call this function from a timer interrupt periodically:
/**
* @brief Initialize DPM (port power role, PWR_IF, CAD and PE Init procedures)
* @retval USBPD status
*/
void USBPD_DPM_TimerCounter(void)
{
I hope you can either improve the user manual or make STM32CubeMX do a better job in generating working code. Thanks!
Best regards,
Christoph
2019-11-08 06:59 AM
Hello @Christoph Rüdisser
Thanks for your feedback... We take in account all these remarks to improve our UserManual.
This comment will be taken in account in the next user manual release.
Important point is that our library need a entry point to schedule a timer expiration every 1ms to be able to manage correctly all the PD timers used in the stack and defined in the specifications.
Regards
Yohann