cancel
Showing results for 
Search instead for 
Did you mean: 

HRTIM timer capture by update event

Joe_Napat
Associate

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 

 

1 REPLY 1
Pierre_Paris
ST Employee

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

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.