Skip to main content
KiptonM
Senior III
Jul 18, 2022 4:42 PM UTC
Solved

Did ST break SysTick in the last update? It used to work. Now it crashes because I think the interrupt vector is not set. Is this one of those known errors? How do I fix it?

When the SysTick interrupt fires the debugger quits.

I cannot figure out where the NVIC_SetVector statement is for the SysTick. I think it is not set. But I can not find the vector table in the debugger to know for sure.

This used to work, But when I updated to the 1.10.1 IDE and 6.6.1-RC2 Build.20220706-1420. It crashes when the systick interrupt happens.

I am using the STM32G051K8T

This topic has been closed for replies.
Piranha
PiranhaBest answer
Principal III
Jul 19, 2022 10:48 PM UTC

That CubeProgrammer description of nBOOT0 and nBOOT1 options is a nonsense. Again a blind trust without checking the real thing - reference manual...

Look at the RM0444 Rev 5, 2.5 Boot configuration, Table 8. Boot modes.

@Houda GHABRI​ 

30 replies

KnarfB
Super User
Jul 18, 2022 5:37 PM UTC

SysTick is part of the ARM core and its interrupt is enabled in SysTick_Config, see SYST_CSR register. The handler is implicitly set already in the g_pfnVectors table, see startup code and implemented in stm32g0xx_it.c. Works here on a Nucleo G071 board without issues with your tool versions.

hth

KnarfB

KiptonM
KiptonMAuthor
Senior III
Jul 18, 2022 5:53 PM UTC

I tried to look at it in the debugger. it says g_pfnVectors <data variable, no debug info>

KnarfB
Super User
Jul 18, 2022 6:04 PM UTC

You can see the source code in the startup file, startup_stm32g071rbtx.s in my case. The startup file also has a default "do nothing" implementation of SysTick_Handler in the startup file. This "weak" declaration is overridden by SysTick_Handler in stm32g0xx_it.c.

You may check that g_pfnVectors table holds the correct handler address at the SysTick offset by inspecting memory in the debugger.

Don't think that a missing SysTick_Handler is issue.

> the debugger quits

Any output, logs? What if you step at assembly level? A fault?

hth

KnarfB

KiptonM
KiptonMAuthor
Senior III
Jul 18, 2022 7:21 PM UTC

Where should I look for output logs?

It is taking a long time to step until the interrupt fires. I am still working on it. Somewhere around 155 loop iterations. No message, The debugger just stops responding I single step. .

KiptonM
KiptonMAuthor
Senior III
Jul 18, 2022 6:06 PM UTC

I found it in the startup_stm32g051k8tx.s and the vector table looks good.

But when I put a breakpoint in the SysTick_Handler program, the debugger crashes before I get to the interrupt there. It appears the interrupt is going somewhere weird, and crashing. I believe that is the only interrupt active and it is initialized by HAL_Init() and the system crashes shortly after HAL_Init() is executed and I am looping on __NOP(); commands. That is all that is running.

Something is wrong.

KiptonM
KiptonMAuthor
Senior III
Jul 18, 2022 6:11 PM UTC

Here is my code:

int main(void)
{
 /* USER CODE BEGIN 1 */
/*
	{
		uint16_t i, j;
		for (i=0;i<525;i++)
		{
			for (j=0;j<60000;j++) __NOP();
		}
 
	}
*/
 /* USER CODE END 1 */
 
 /* MCU Configuration--------------------------------------------------------*/
 
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();
 
 /* USER CODE BEGIN Init */
 
 /* USER CODE END Init */
 
 /* Configure the system clock */
 //SystemClock_Config();
 
 /* USER CODE BEGIN SysInit */
 
 /* USER CODE END SysInit */
 
 /* Initialize all configured peripherals */
// MX_GPIO_Init();
 // MX_DMA_Init();
// MX_ADC1_Init();
// MX_I2C1_Init();
// MX_TIM2_Init();
// MX_TIM3_Init();
// MX_TIM14_Init();
// MX_USART1_UART_Init();
// MX_USART2_UART_Init();
 
 /* Initialize interrupts */
// MX_NVIC_Init();
 /* USER CODE BEGIN 2 */
 
 //__disable_irq();
 /*
 ENCODER_POWER_OFF; // Make sure encoder is off so it can start correctly.
 print_debug_str("Encoder Power Off\r\n");
 
 
 
 TASK_PIN_L;
 TP2_L;
 DIO2_L;
 DIO3_L;
 DIO4_L;
 
 if (isDebug(DEBUG_verify_memory_structures))
 {
	 verify_memory_structures();
 }
*/
 __NOP();
 {
 
	 uint16_t i;
	 for (i=0;i<1000;i++)
	 {
		 __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); // 20
		 __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); // 40
		 __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); // 60
		 __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); // 80
		 __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); __NOP(); // 100
	 }
 }
 //ADC_init();
 __NOP();

I also put a breakpoint in SysTic_Handler() found in stm32g0xx_it.c but the debugger crashes before I get there.

/**
 * @brief This function handles System tick timer.
 */
void SysTick_Handler(void)
{
 /* USER CODE BEGIN SysTick_IRQn 0 */
 
 /* USER CODE END SysTick_IRQn 0 */
 HAL_IncTick();
 /* USER CODE BEGIN SysTick_IRQn 1 */
 
 /* USER CODE END SysTick_IRQn 1 */
}

Piranha
Principal III
Jul 18, 2022 6:50 PM UTC

Open the memory view at 0x0800003C and check whether it contains the SysTick_Handler() address.

KiptonM
KiptonMAuthor
Senior III
Jul 18, 2022 7:44 PM UTC

0693W00000QLSZtQAP.pngFrom the .map file.

 .text.SysTick_Handler

        0x0000000008005778    0x8 ./Core/Src/stm32g0xx_it.o

        0x0000000008005778        SysTick_Handler

Why is it off by 1? 0x08005779? Should be a number divisible by 4 I would think.

It looks like all the vectors are odd numbers.

The Startup file has:

.section .isr_vector,"a",%progbits
 .type g_pfnVectors, %object
 .size g_pfnVectors, .-g_pfnVectors
 
g_pfnVectors:
 .word _estack
 .word Reset_Handler
 .word NMI_Handler
 .word HardFault_Handler
 .word 0
 .word 0
 .word 0
 .word 0
 .word 0
 .word 0
 .word 0
 .word SVC_Handler
 .word 0
 .word 0
 .word PendSV_Handler
 .word SysTick_Handler
 .word WWDG_IRQHandler /* Window WatchDog */
 .word PVD_IRQHandler /* PVD through EXTI Line detect */
 .word RTC_TAMP_IRQHandler /* RTC through the EXTI line */
 .word FLASH_IRQHandler /* FLASH */
 .word RCC_IRQHandler /* RCC */
 .word EXTI0_1_IRQHandler /* EXTI Line 0 and 1 */
 .word EXTI2_3_IRQHandler /* EXTI Line 2 and 3 */
 .word EXTI4_15_IRQHandler /* EXTI Line 4 to 15 */
 .word 0 /* reserved */
 .word DMA1_Channel1_IRQHandler /* DMA1 Channel 1 */
 .word DMA1_Channel2_3_IRQHandler /* DMA1 Channel 2 and Channel 3 */
 .word DMA1_Ch4_7_DMAMUX1_OVR_IRQHandler /* DMA1 Channel 4 to Channel 7, DMAMUX1 overrun */
 .word ADC1_COMP_IRQHandler /* ADC1, COMP1 and COMP2 */
 .word TIM1_BRK_UP_TRG_COM_IRQHandler /* TIM1 Break, Update, Trigger and Commutation */
 .word TIM1_CC_IRQHandler /* TIM1 Capture Compare */
 .word TIM2_IRQHandler /* TIM2 */
 .word TIM3_IRQHandler /* TIM3 */
 .word TIM6_DAC_LPTIM1_IRQHandler /* TIM6, DAC & LPTIM1 */
 .word TIM7_LPTIM2_IRQHandler /* TIM7 & LPTIM2 */
 .word TIM14_IRQHandler /* TIM14 */
 .word TIM15_IRQHandler /* TIM15 */
 .word TIM16_IRQHandler /* TIM16 */
 .word TIM17_IRQHandler /* TIM17 */
 .word I2C1_IRQHandler /* I2C1 */
 .word I2C2_IRQHandler /* I2C2 */
 .word SPI1_IRQHandler /* SPI1 */
 .word SPI2_IRQHandler /* SPI2 */
 .word USART1_IRQHandler /* USART1 */
 .word USART2_IRQHandler /* USART2 */
 .word LPUART1_IRQHandler /* LPUART1 */

Which looks right.

KnarfB
Super User
Jul 18, 2022 7:48 PM UTC

> Why is it off by 1? 0x08005779? Should be a number divisible by 4 I would think.

LSB 1 indicates thumb mode, looks correct.

KnarfB
Super User
Jul 18, 2022 7:53 PM UTC

You say the debugger crashes. Do you get any useful message from it?

In the Debug Config Debugger tab you can set the ST-LINK freq. Try setting to a low value to compensate for possibly weak ST-LINK connection. There is also a Misc/Log to file checkbox which you might check.

hth

KnarfB

KiptonM
KiptonMAuthor
Senior III
Jul 18, 2022 8:02 PM UTC

So I still do not know why when it calls this interrupt the debugger crashes. I was guessing the vector was wrong, but it appears correct.

I have a breakpoint for the first instruction in the ISR. It never breaks. The debugger just stops about 1 ms after we initialize the SysTick. That is what made me think it was a vector error. But everything looks good.

So I am back to not having a clue as to why it is no longer working. It has been working for more than 6 months, After I upgraded to the new version of IDE and MX it stopped working.