Skip to main content
Associate III
November 17, 2024
Solved

Wait but MCU is unblocked

  • November 17, 2024
  • 5 replies
  • 7614 views

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);

		 }
}

 

 

Best answer by MM..1

@XooM wrote:

timer16 and SerialWire what do you want me to do


Ahh boy select as on my image  Chekbox on serial wire when you used debuger this is good point and select TIM16 as your application timebase , MX then for you after generate code changes delay control from systick to TIM16 and setup 1ms. No more is required. Test toggle with this

5 replies

Tesla DeLorean
Guru
November 17, 2024

It would rely on PC13 and PA2 being low before it gets to the timeout. And presumably you want it to turn off either way

 

Do all your INPUTs and OUTPUTs work otherwise? And it's just the sequencing logic that's broken?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MM..1
Chief III
November 17, 2024

Is your 

PA10_On

volatile?  When not and optimize level is more as 0 your code never will work. Optimizer remove line

PA10_On=1;

 

XooMAuthor
Associate III
November 17, 2024
PA10_On=1;

If I remove this line, PB14 will always remain in the SET position.

As long as PA2+PC13 continues to come, PB14 will be SET.

MM..1
Chief III
November 17, 2024

You dont ask this ? PB14 not go to 0 say is always 1.

And i recommend add volatile not remove

volatile int PA10_On = 0;

, but i mean we next 7 days try show you mistakes. Better is try help you create working code.

What you mean?

XooMAuthor
Associate III
November 18, 2024

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. 

MM..1
Chief III
November 18, 2024

Know you how debug code ?

XooMAuthor
Associate III
November 18, 2024

I don't know

Tesla DeLorean
Guru
November 19, 2024

Did we ever establish what memory is mapped at Zero in yet another thread about the issue of not getting SysTick interrupts.

Didn't see a dump of 0x00000000 vs 0x08000000

Let's try not going in circles for another week.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
XooMAuthor
Associate III
November 19, 2024

I can't understand what you're saying. Can you tell me exactly what I should do? And I want to state again that I'm a beginner. Is it a hardware problem that the systick is not working? If it can be solved, what exactly should I write and where? Can you please tell me step by step. I don't understand some of what you're saying at all, I'm very sorry.

Tesla DeLorean
Guru
November 19, 2024

Perhaps start with a memory view in the debugger.

Anyone at your place of work who can guide/support you?

Check what BOOT0 pin is doing in your design. Pulled Low?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Lead III
November 19, 2024

what is the value of the return code of HAL_InitTick()?
Have you tried the other startup file (.bak)? The modification may be incorrect. If interrupt vector table not correct interrupts can fire and call the wrong code.
Do you use some kind of bootloader? Did the original application use a different linker file? It seems you are using the default linker file.

"Kudo posts if you have the same problem and kudo replies if the solution works.Click ""Accept as Solution"" if a reply solved your problem. If no solution was posted please answer with your own."