cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L071 can't disable SysTick

ypiotrp
Senior

Hi,

I've got a problem with STM32L071 and SysTick. I got a two programs written for this MCU - bootloader and the main app.

The bootloader uses HAL dirven with SysTick. Standard SysTick_Handler() function is responsible for handling the interrupts coming from Systick. After the MCU startup I check some things in the bootloader and then make a jump to the main app. Before the jump I disable all interrupts using __disable_irq();, but I don't turn off the Systick. Unfortunately I can't make any changes in the bootloader.

In the main app I use TIM6 to drive HAL, because I use SysTick for driving the FreeRTOS. Function resposible for handling the interrupts from SysTick is xPortSysTickHandler(). In main() I do the HAL_Init() and __enable_irq();. After that the SysTick generates an interrupt that calls xPortSysTickHandler() which leads to HardFault.

I think the reason of the HardFault is that I call xPortSysTickHandler() before I manage to initialize the FreeRTOS. I tried to diable the SysTick using following lines of code:

SysTick->CTRL &= ~(SysTick_CTRL_CLKSOURCE_Msk |
                   SysTick_CTRL_TICKINT_Msk   |
                   SysTick_CTRL_ENABLE_Msk);
SCB->ICSR |= SCB_ICSR_PENDSVCLR_Msk | SCB_ICSR_PENDSTCLR_Msk;

Even with this in the beginning of the main() I get the interrupt from SysTick, which leads straight to HardFault. Is there any other way to disable the SysTick?

Regards,

Piotr

0 REPLIES 0