Skip to main content
Associate III
Feb 12, 2024 8:41 PM UTC
Solved

Cannot read voltage measurement inside UCPD monitor

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.
    HFISTM
    HFISTMBest answer
    ST Employee
    Feb 16, 2024 11:29 AM UTC

    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

    3 replies

    HFISTM
    HFISTMBest answer
    ST Employee
    Feb 16, 2024 11:29 AM UTC

    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
    Associate III
    Feb 17, 2024 2:02 PM UTC

    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?

    HFISTM
    ST Employee
    Feb 19, 2024 8:12 AM UTC

    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.