Skip to main content
Graduate
May 10, 2025
Solved

STM32H733VGT6 can't get interrupts working. Not sure if the problem is in software or in my board.

  • May 10, 2025
  • 2 replies
  • 600 views

I am trying to drive a lc resonator from a h bridge. Frequency of the resonator changes when inductor is loaded. 

TIM15 creates the complimentary PWM for the H bridge. I need TIM2 to read the new frequency of the resonator so i can adjust the PWM frequency of TIM15. TIM2 will be reading a square wave.

I tried this guide(and every other one I could find). I tried DMA. I tried interrupts. I even put a breakpoint inside the HAL_TIM_IC_CaptureCallback. It didn't even get triggered.

https://community.st.com/t5/stm32-mcus/how-to-use-the-input-capture-feature/ta-p/704161

At this point i am not sure if my code is wrong or if there is an actual problem with the board. 

Would it be possible for someone to send me a code for TIM2 interrupt that is confirmed working or test my code on a stm32 that is confirmed good?

I am questioning my sanity. The board programs and debugs just fine. cubeide or cubeprogrammer gives no error codes.

here is all the edits I have done to my main.c file

/* USER CODE BEGIN 0 */
uint32_t H_freq;
uint32_t ARR_tim15;
uint32_t frequency;


uint32_t captureValue = 0;

uint32_t previousCaptureValue = 0;

uint32_t frequency = 0;
float freq;
float duty;
float TIMER_CLOCK_FREQ;
/* USER CODE END 0 */



 /* USER CODE BEGIN 1 */
void pwm_frequency_set() //H bridge pwm frequency
{

				 ARR_tim15=80000000/H_freq;
				 TIM15->ARR = ARR_tim15; // counter period for timer 15
				 TIM15->CCR1 = ARR_tim15/2; // duty cycle for timer 15

				 return;
}

void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) {

	H_freq = 20000;
	 	pwm_frequency_set();


if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {

captureValue = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1);

frequency = HAL_RCC_GetPCLK1Freq() / (captureValue - previousCaptureValue);

previousCaptureValue = captureValue;

}

}

 /* USER CODE END 1 */


 /* USER CODE BEGIN 2 */
HAL_TIM_PWM_Start(&htim15, TIM_CHANNEL_1);
HAL_TIMEx_PWMN_Start(&htim15, TIM_CHANNEL_1);
HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_1); // Primary channel - rising edge
HAL_TIM_IC_Start(&htim2, TIM_CHANNEL_2); // Secondary channel - falling edge

 /* USER CODE END 2 */


 /* USER CODE BEGIN WHILE */
H_freq = 10000;
 	pwm_frequency_set();
 	 while (1)
{
 /* USER CODE END WHILE */
    This topic has been closed for replies.
    Best answer by oyalç.1

    problem was that the BOOT0 pin was not soldered properly. after soldering it to GND issue went away.

    2 replies

    Graduate
    May 10, 2025

    We use in many H7xx designs interrupts and work great .

    I will be favorable to say it is a sw problem.

    But to guess where, try to make a subset of your deisgn, post the code, let us try on our hw and give some better feedback.

    oyalç.1Author
    Graduate
    May 10, 2025

    I attached the full project as a zip file.  The reason why I am suspicious from hardware is because the microcontroller is soldered to a generic LQFP 100 breakout board. I have added bunch of caps to power pins but some capacitors are as far away as 10mm. . It programs just fine but i still don't trust it.

     

    Full project for now is just reading the return frequency and adjusting the output frequency according to it.

     

    Graduate
    May 10, 2025

    Let us not waste time - try with a sound board like a Nucleo or other eval board - if it work, then we discuss sw 

    oyalç.1AuthorAnswer
    Graduate
    June 6, 2025

    problem was that the BOOT0 pin was not soldered properly. after soldering it to GND issue went away.