Skip to main content
Aatif Shaikh1
Associate III
March 6, 2020
Question

How to De-init the SysTick clock?

  • March 6, 2020
  • 6 replies
  • 3225 views

Hello,

Currently, I'm working on a project in which the boat-loader is already present. Now, in the boat-loader, there are several things which I'm not using i.e Systick clock, DMA etc. So, I want to De-init all the unnecessary peripherals to run the CPU more efficiently. Unfortunately, I couldn't find anything related to how can I Dinit the Systick.

I'm using STM32F103CBT6 and Standard peripheral Library ( STSW-STM32054 ).

This topic has been closed for replies.

6 replies

Mike_ST
Technical Moderator
March 6, 2020

Try  SysTick->CTRL = 0;

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
Piranha
Principal III
March 7, 2020

Or even better - do not initialize anything! Here is a much better and simpler approach to bootloader design:

https://community.st.com/s/question/0D50X0000AFpTmUSQV/using-nvicsystemreset-in-bootloaderapplication-jumps

Aatif Shaikh1
Associate III
March 12, 2020

I'm not designing the bootloader, as it's already designed and present in the ~20k devices on the field. Hence, we can't modify every device's bootloader.

Previously, the bootloader and main code project files were written in IAR-ID, setting the main clock source to 24Mhz and the timer functionality was implemented using Systick at 25ms-interrupt.

Now, keeping the bootloader same, we've improvised the main code, moved the project on KIEL uVision, setting the main clock source to 64Mhz and the timer functionality was implemented using Timer-3 at 1ms-interrupt.

Unfortunately, whenever I'm initializing the Timer-3 in the main code, it's getting hanged and due to watchdog-timer, the code keeps getting reset.

Tesla DeLorean
Guru
March 12, 2020

Yeah, so lets unpack that a bit

Get a proper Hard Fault handler running so you can get some actionable diagnostics before the thing watch-dogs.

Check the interrupt handler for the TIM3 binds correctly, and you've got SCB->VTOR pointing the vector table to the right location.

Have the SysTick kick the watchdog for the time being, and set the preempt/priority of the SysTick so it cuts through everything

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Aatif Shaikh1
Associate III
March 12, 2020

I'm having a bit peculiar problem, after the code jump to the main from boot loader, the moment I'm initializing the timer 3, my system getting hanged.

Although, I'm not able to resolve this issue so far.

turboscrew
Senior III
March 12, 2020

And you can't find out the reason of hanging?

Do you use JTAG/SWD debugger?

You might want to put a breakpoint in the code and see if HAL is busy or something.

You can (usually) stop watchdog during debug halt if you set the DBG_WWDG_STOP- or DBG_IWDG_STOP-bit (dependin on the used watchdog) in DBGMCU_CR-register.

A dirty temporary way is:

*(uint32_t *)0xE004 2004 |= 0x00000300;

Piranha
Principal III
March 21, 2020

I would safely toss out almost all configuration that bootloader does and start from a "clean" state.

  1. Disable interrupts on CPU.
  2. Disable SysTick and set it to default values.
  3. Enable HSI and switch system clock to it.
  4. Disable all other clocks and set RCC registers to default values.
  5. Set FLASH registers to default values.
  6. Reset all peripherals.
  7. Disable all interrupts in NVIC.
  8. Clear all pending interrupts in NVIC.
  9. Relocate VTOR.
  10. Execute DSB.
  11. Enable interrupts on CPU.

After something like this with probably some other modifications just start as normally.

Aatif Shaikh1
Associate III
March 23, 2020

thanks Everyone, with all your help, I've successfully solved the issue.

  1. VECT_TAB_OFFSET set to the ( base address of main code - 0x8000000 ).
  2. disable and De-init all the peripherals (SysTick->CTRL = 0; really does work for disabling the SysTick).
  3. Clear the pending interrupt request.
  4. Re-Init all the peripherals.