Skip to content

Commit 5d619e5

Browse files
committed
SysTick initialization problem fixed in tx_initialize_low_level.s
Problem with first system tick was detected, it needs much more time for the first tick as it's defined. The reason for this behavior is incorrect initialization of the SysTick timer in the port file for the Cortex-M0. It doesn't reset the SysTick Current Value Register despite the fact that its value is not initialized at startup (see https://developer.arm.com/documentation/dui0552/a/cortex-m3-peripherals/system-timer--systick). So if we have 0xFFFFFF (this register has 24-bit), it means we will get about 256*256*256 / 48000000 for the tact frequency of 48MHz to reach the zero, that makes 350ms delay at startup.
1 parent 1b2995c commit 5d619e5

4 files changed

Lines changed: 12 additions & 0 deletions

File tree

ports/cortex_m0/ac5/example_build/tx_initialize_low_level.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ _tx_initialize_low_level
176176
; /* Configure SysTick. */
177177
;
178178
LDR r0, =0xE000E000 ; Build address of NVIC registers
179+
LDR r1, =0
180+
STR r1, [r0, #0x10] // Reset SysTick Control
181+
STR r1, [r0, #0x18] // Reset SysTick Counter Value
179182
LDR r1, =SYSTICK_CYCLES
180183
STR r1, [r0, #0x14] ; Setup SysTick Reload Value
181184
MOVS r1, #0x7 ; Build SysTick Control Enable Value

ports/cortex_m0/gnu/example_build/tx_initialize_low_level.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ _tx_initialize_low_level:
134134
@ /* Configure SysTick for 100Hz clock, or 16384 cycles if no reference. */
135135
@
136136
LDR r0, =0xE000E000 @ Build address of NVIC registers
137+
LDR r1, =0
138+
STR r1, [r0, #0x10] // Reset SysTick Control
139+
STR r1, [r0, #0x18] // Reset SysTick Counter Value
137140
LDR r1, =SYSTICK_CYCLES
138141
STR r1, [r0, #0x14] // Setup SysTick Reload Value
139142
LDR r1, =0x7 // Build SysTick Control Enable Value

ports/cortex_m0/iar/example_build/tx_initialize_low_level.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ _tx_initialize_low_level:
125125
; /* Configure SysTick. */
126126
;
127127
LDR r0, =0xE000E000 ; Build address of NVIC registers
128+
LDR r1, =0
129+
STR r1, [r0, #0x10] // Reset SysTick Control
130+
STR r1, [r0, #0x18] // Reset SysTick Counter Value
128131
LDR r1, =SYSTICK_CYCLES
129132
STR r1, [r0, #0x14] ; Setup SysTick Reload Value
130133
MOVS r1, #0x7 ; Build SysTick Control Enable Value

ports/cortex_m0/keil/example_build/tx_initialize_low_level.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ _tx_initialize_low_level
176176
; /* Configure SysTick. */
177177
;
178178
LDR r0, =0xE000E000 ; Build address of NVIC registers
179+
LDR r1, =0
180+
STR r1, [r0, #0x10] // Reset SysTick Control
181+
STR r1, [r0, #0x18] // Reset SysTick Counter Value
179182
LDR r1, =SYSTICK_CYCLES
180183
STR r1, [r0, #0x14] ; Setup SysTick Reload Value
181184
MOVS r1, #0x7 ; Build SysTick Control Enable Value

0 commit comments

Comments
 (0)