Skip to main content
Visitor II
November 10, 2023
Question

HRTIM timer capture by update event

  • November 10, 2023
  • 1 reply
  • 1309 views

Hi

I'm using HRTIM in STM32G474RE to generate a complementary PWMs and trying to capture the frequency of the PWMs by using the capture 1, the trigger sources is "The update event triggers the capture"

Joe_Napat_0-1699582162942.png

However, when I was debugging the code, the value of CPT1x is always zero

Joe_Napat_1-1699582278693.png

I guessed the capture function does not work, could you please help me to figure out what's going wrong? 

Thank you 

 

    This topic has been closed for replies.

    1 reply

    ST Employee
    November 16, 2023

    Hello @Joe_Napat,

    Thank you for your question !

    Here some remarks and interrogations :

    • As I understand, your application need a second timer (the Timer A is busy to generate a PWM). You can choose Timer B to count-up with a fixed frequency (lower than Timer A) and every time the Timer A overflow you capture Timer B (and store it in a array for example), you can reset Timer B every X capture... 
    • Are you sure your PWM is generated ? If not, you can check the package example STM32CubeG4 here. (Under the root  "\STM32Cube_FW_G4_V1.5.0\Projects\NUCLEO-G474RE\Examples\HRTIM\")
    • Can you confirm you have the interrupt callback function Capture1EventCallback() in your code and you enter by adding a breakpoint in it? (check in NVIC settings under CubeMX)
    • Are you configuring the capture unit through this API HAL_HRTIM_WaveformCaptureConfig() ? This operation is necessary and consists of specifying the source triggering the capture (in your application when the Timer A overflow right ?) On your screen, we also see the HRTIM_CPT1ACR (at the reset value : 0x0) which is the register to program for using the capture unit on Timer A.
    • Can you tell me your application please ?

    I am waiting for your answer and don't hesitate to share some part of your code.

    Best Regards,

    Pierre