2024-11-17 06:02 AM - edited 2024-11-19 02:37 AM
I haven't been able to wait 500ms without affecting the timers for 7 days.
In this block, doesn't PB14 become "0" after 500ms?
Even if I use comment lines, it doesn't work.
Note: volatile uint32_t Counter = 0;
The "Counter" variable is incremented every 1ms with Timer16.
** STM32F030C6T6 I'm using.
** Own PCB board..
*** Note: Card of a working system.. There is no card design error.
if(htim->Instance==TIM16)
{
Counter++;
if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13)==0)
{
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_2)==0)
{
if(PA10_On==0)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12,GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14,GPIO_PIN_SET);
Counter=0;
PA10_On=1;
// Tick_PA10_On= HAL_GetTick();
// PA10_On=1;
}
else
{
if(Counter>500) // if((HAL_GetTick()-Tick_PA10_On)>=500)
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_14,GPIO_PIN_RESET);
Counter=501;
}
}
}
else
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12,GPIO_PIN_SET);
}
}
else
{
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12,GPIO_PIN_RESET);
}
}
Solved! Go to Solution.
2024-11-18 09:18 AM
I give energy to the circuit. I explain what I did in order.
1- I give PC13=0 (No output is active)
2- I give PA2=0, PB14 =1 becomes.. (it waits like that. It is not zero).
So it did not work, sorry.
2024-11-18 10:03 AM
I added a project made with Stm32CubeIDE that only contains the following codes. Unfortunately, even this code doesn't work. I'm going to go crazy if I can't find where I made a mistake.
while (1)
{
if(a==0)
{
TickTime=HAL_GetTick();
a=1;
}
if(a==1 && (HAL_GetTick()-TickTime)>=500)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);
a=0;
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
The file is attached and only this code is written, there is no other code but it does not work.
2024-11-18 10:37 AM
Know you how debug code ?
2024-11-18 10:48 AM
I don't know
2024-11-18 10:59 AM
then switch to it.c and click on line set break point , on left click play button learn use debuger ...
2024-11-18 11:39 AM
The program is starting to go crazy. This stm32 is going to drive me crazy. I made a mistake by giving up on MicroChip.
2024-11-18 12:26 PM
HAL_delay command does not work either. Is there a solution for this?
2024-11-18 12:47 PM
Make sure that SysTick is causing HAL_GetTick() to advance.
If it is not, then HAL_Delay() will not work.
Make sure all the input and output lines are functional.
Need to start from first principles, and confirm what is and what isn't working.
2024-11-18 01:03 PM
I have written nothing but a simple blink program.HAL_Delay(500); is not working.I noticed that while I was suspecting that the GetTick(); function was not working.Then when I made a simple Toggle query, it turned out that HAL_Delay() was not working. I don't know how to solve this.
2024-11-18 09:47 PM
Seems you choice ST versions with some bugy frameworks. I understand your frustration , but try remove systick and use other timebase. Start with open ioc and free TIM16 disable it.
Then choice here
and test your HAL_Delay 500 toggle or my code.