STM32: Code after "SysTick_Config()" isn't executed
Hi there
I had working code that I resumed working on recently and had weird behavior.
Digging into it there's something going on with the SysTick.
Just now, I put the Systick configuration at the very beginning of the main (before I first initialized my hardware class), and now in Debug mode, my "hw.init()" doesn't even get a instruction marker on the side bar. This means, that this code isn't executed at all!
Is there maybe sth I have to check in the Startup.s file? Though I cannot see, that I modified anything there.
.macro ISR_HANDLER name=
.section .vectors, "ax"
.word \name
.section .init, "ax"
.thumb_func
.weak \name
\name:
1: b 1b /* endless loop */
.endm
.macro ISR_RESERVED
.section .vectors, "ax"
.word 0
.endm
.syntax unified
.global reset_handler
.section .vectors, "ax"
.code 16
.global _vectors
_vectors:
.word __stack_end__
#ifdef STARTUP_FROM_RESET
.word reset_handler
#else
.word reset_wait
#endif /* STARTUP_FROM_RESET */
ISR_HANDLER NMI_Handler
ISR_HANDLER HardFault_Handler
ISR_HANDLER MemManage_Handler
ISR_HANDLER BusFault_Handler
ISR_HANDLER UsageFault_Handler
ISR_RESERVED
ISR_RESERVED
ISR_RESERVED
ISR_RESERVED
ISR_HANDLER SVC_Handler
ISR_HANDLER DebugMon_Handler
ISR_RESERVED
ISR_HANDLER PendSV_Handler
ISR_HANDLER SysTick_Handler
#include __VECTORS
.section .vectors, "ax"
_vectors_end:
#ifdef VECTORS_IN_RAM
.section .vectors_ram, "ax"
_vectors_ram:
.space _vectors_end-_vectors, 0
#endif
.section .init, "ax"
.thumb_func
reset_handler:
#ifndef __NO_SYSTEM_INIT
ldr r0, =__RAM_segment_end__
mov sp, r0
bl SystemInit
#endif
#ifdef VECTORS_IN_RAM
ldr r0, =__vectors_load_start__
ldr r1, =__vectors_load_end__
ldr r2, =_vectors_ram
l0:
cmp r0, r1
beq l1
ldr r3, [r0]
str r3, [r2]
adds r0, r0, #4
adds r2, r2, #4
b l0
l1:
#endif
#if !defined(__NO_FPU) && !defined(__SOFTFP__)
// Enable CP11 and CP10 with CPACR |= (0xf<<20)
movw r0, 0xED88
movt r0, 0xE000
ldr r1, [r0]
orrs r1, r1, #(0xf << 20)
str r1, [r0]
#ifndef __NO_RUNFAST_MODE
isb
dsb
vmrs r0, fpscr
orrs r0, r0, #(0x3 << 24) // FZ and DN
vmsr fpscr, r0
// clear the CONTROL.FPCA bit
mov r0, #0
msr control, r0
// FPDSCR similarly
movw r1, 0xEF3C
movt r1, 0xE000
ldr r0, [r1]
orrs r0, r0, #(0x3 << 24) // FZ and DN
str r0, [r1]
#endif
#endif
#ifndef __ARM_ARCH_6M__
/* Configure vector table offset register */
ldr r0, =0xE000ED08
#ifdef VECTORS_IN_RAM
ldr r1, =_vectors_ram
#else
ldr r1, =_vectors
#endif
str r1, [r0]
#endif
b _start
#ifndef __NO_SYSTEM_INIT
.thumb_func
.weak SystemInit
SystemInit:
bx lr
#endif
#ifndef STARTUP_FROM_RESET
.thumb_func
reset_wait:
1: b 1b /* endless loop */
#endif /* STARTUP_FROM_RESET */
-
Hello Michael,
I'm not sure what you mean.
In the past I hade a related question to this Config to which you also replied.
I think I'm also struggling with the setup of my hardware. There is a "SystemInit" command, that can be omitted via preprocessor setting. Would you include or exclude it? -
Hi Michael,
Today I learned that "SystemInit" by default is just a blank function identifier and if you need it you have to implement it by yourself. Same with "SystemCoreClockUpdate".
So as I initialize the clocks and the other hardware peripherals inside the hw.init() I don't need SystemInit.
Also now I know, that the hardware init should be called before the SystickConfig.
I also realized, that some of my source files have a "modified properties" tag on it. Maybe by accident I modified these files instead of the whole project. Do you know how I can reset these single files?
Please sign in to leave a comment.
Comments
7 comments