Skip to main content
Graduate II
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);

		 }
}

 

 

    This topic has been closed for replies.
    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

    Graduate II
    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?

    Graduate II
    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
    Graduate II
    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.

    Graduate II
    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
    Graduate II
    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. 

    Graduate II
    November 18, 2024

    Know you how debug code ?

    XooMAuthor
    Graduate II
    November 18, 2024

    I don't know

    Graduate II
    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.

    XooMAuthor
    Graduate II
    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.

    Graduate II
    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?

    Graduate II
    November 19, 2024

    unsigned_char_array_1-1732015972986.png

    Please give pins functional names. It makes it easier to use it in code using the generated defines in main.h:

    #define YOURPINNAME_Pin GPIO_PIN_14
    #define YOURPINNAME_GPIO_Port GPIOB

    I noticed pin PINB12 and PINC13 referenced in your start post are missing in the configuration. Please configure all iopins

    XooMAuthor
    Graduate II
    November 19, 2024

    I'll take care of them, so why isn't Hal_delay working?
    My problem is exactly that the hal_delay function isn't working.
    I didn't care about the names because I was writing a test program.

    Graduate II
    November 19, 2024

    @XooM wrote:

    so why isn't Hal_delay working?
    My problem is exactly that the hal_delay function isn't working.


    Because you are not calling Hal_delay() anywhere in your code.

    Graduate II
    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.