Skip to main content
Graduate II
February 12, 2024
Solved

Cannot read voltage measurement inside UCPD monitor

  • February 12, 2024
  • 1 reply
  • 1829 views

I have followed this STM wiki tutorial about basic PD Sink. Everything is running according to it, but I am unable to see voltage and current measurement inside UCPD monitor. I have also followed the set-up of debugging button which is working correctly and prints the voltage inside trace. But the measurement graph is unfortunately blank. Where might be the problem?

github: link 

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

    Hello,

    I just had a deep look in your code on GitHub, and it seems you are not incrementing the DPM and GUI timebase.
    Please try with adding these lines in your main.c file:

     

    void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
    {
     /* USER CODE BEGIN Callback 0 */
     /* USER CODE END Callback 0 */
     if (htim->Instance == TIM2) {
     HAL_IncTick();
     }
     /* USER CODE BEGIN Callback 1 */
     USBPD_DPM_TimerCounter();
     GUI_TimerCounter();
     /* USER CODE END Callback 1 */
    }​

     

    Regards

    1 reply

    HFISTMAnswer
    ST Employee
    February 16, 2024

    Hello,

    I just had a deep look in your code on GitHub, and it seems you are not incrementing the DPM and GUI timebase.
    Please try with adding these lines in your main.c file:

     

    void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
    {
     /* USER CODE BEGIN Callback 0 */
     /* USER CODE END Callback 0 */
     if (htim->Instance == TIM2) {
     HAL_IncTick();
     }
     /* USER CODE BEGIN Callback 1 */
     USBPD_DPM_TimerCounter();
     GUI_TimerCounter();
     /* USER CODE END Callback 1 */
    }​

     

    Regards

    MaroshAuthor
    Graduate II
    February 17, 2024

    Thanks a lot, this works like a charm. So the problem was that there wasn't any linkage between timer and GUI, so the software couldn't count up the declared interval?

    ST Employee
    February 19, 2024

    Glad to hear that !
    Yes that is right. The HAL tick that is used by the HAL_Delay function an other timeout utilities is based on a 1 ms tick that is incremented by HAL_IncTick. The USBPD MW and the GUI utility also needs their time tracking variable to be incremented, at the same place. In your case you are using a timer as the 1ms tick source, so you will find those 3 function call in the HAL_TIM_PeriodElapsedCallback, called each ms.