cancel
Showing results for 
Search instead for 
Did you mean: 

Delay, multi milliseconds, on the STM32F0, again..

XooM
Senior

where I wrote it among the codes.. // Here I have to wait 500ms.
Can you help me to prevent the timers from being affected by this wait?
Can you give me the codes that I will add. Because I am very confused..

I tried many things but they all stopped the interrupts..

 

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{

	if(htim->Instance==TIM1)
	{
		
	if(input1==0) 
	{
		HAL_GPIO_WritePin(GPIOA, GPIO_Pin_1, GPIO_PIN_SET);
		// Here I have to wait 500ms.
		HAL_GPIO_WritePin(GPIOA, GPIO_Pin_1, GPIO_PIN_RESET);
	}

}

 

 

 

 

 

70 REPLIES 70

@XooM wrote:

I don't have a program in the while loop. My program is in timer1 and timer16. When I do what you said, it gives an error, so I added the file.

I did everything you said but the errors are not decreasing.
Could you please look at my project file? Please I am stuck and cannot proceed.


What error? Added what file? Explain in more detail.

If you're talking about the latest project you've uploaded, did you even look at my main.h file? 

extern and #include are needed just like i have in my main.h which you need to add to your main.h

 

.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

I added this to my previous file. I forgot to add it to the project I created from scratch called test3.

Bu dosyayı benimkine ekledim ve hala hata veriyor.

when you added the prototypes, you didn't add the semi colon

KarlYamashita_0-1731916332006.png

 

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
Karl Yamashita
Lead III

I've attached a project that uses your STM32F030C6 that compiles with no errors.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

 

XooM_0-1731920812674.png

PA10_off does not work after 1sec. PA10 "1" is always
It should be "0" after 1sec but timercallback does not work.

 

Can you try it on your own board? It definitely doesn't work.

I have been trying to make a 500 ms delay since the first message I opened in the topic.
Unfortunately, I couldn't take any steps forward. It always blocked the mcu and timers.
TimerCallbackTimerStart(&timerCallback, PA10_Off, 500, TIMER_NO_REPEAT);
I was very hopeful about the function above.

 

PollingRoutine.c/h I will not use these files, my aim is to stop the pin I want after 500ms.

XooM
Senior

XooM_0-1731922612410.png

If the PA10_off function was used after 1 second, it would be something to look for..

My aim was to make a PAx? that was active anywhere in my project passive after a period of 100 200 500ms... but it doesn't work.


@XooM wrote:

 

XooM_0-1731920812674.png

PA10_off does not work after 1sec. PA10 "1" is always
It should be "0" after 1sec but timercallback does not work.

 


It's because you keep calling it in a while loop. Each time you call it, it resets the callback timer.

Look at my signature and watch the video

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.