Hello Forum
It seems that I am asking for some help every day. Feel free to move this to the beginner section if you feel it is more appropriate.
I have my STM32 board running. And I have implemented some basic functions. I have a blinking LED, I can detect when a button is pushed, I have a PWM signal out to one of the pins. I had some issues previously, you helped me here.
https://www.eevblog.com/forum/microcontrollers/stm32f103t8u6-not-recognized-by-cubeide-as-genuine/Now I have problems getting the interrupt functions to work.
Firstly I wanted the buttons to be managed by interrupt. There are many guides out there, here is one of them.
When I follow this example, as soon as I push the button the MCU will freeze. I have a blinking LED going, if the button is pushed when the LED is on, it stays on, of LED is of it stays of.
I can use the NRST and try again, this issue can be repeated again and again.
I can have a IF function in the main while loop for the buttons, and there it will work without issue.
I could live with having the buttons in the while loop.
But then I needed a timer. I need one of the buttons provide a different function if it is pressed for a long time. And the best solution I could find would be to use a timer
Similar to this example.
https://deepbluembedded.com/stm32-timer-interrupt-hal-example-timer-mode-lab/First I get it to blink a LED, later I can use it to count time and detect how long the button has been pressed.
But when the function to start timer is added in main.c the board will not work.
I can remove this line, and it will work
HAL_TIM_Base_Start_IT(&htim4);
It is in this section in main.c:
/* USER CODE BEGIN 2 */
//Start PWM timer
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);
//Start the timekeeping timer
HAL_TIM_Base_Start_IT(&htim4);
int pulse = 0 ;
/* USER CODE END 2 */
I dont know if something is wrong with my chip, or if there is some small setting that I have wrong
Help would be much appreciated.