STM32H7 rešitev
// Podane so samo dodane spremenljivke, glavni program in podprogrami
// SysTick Timer definitions
.equ SCS_BASE,0xe000e000
.equ SCS_SYST_CSR,0x10// Control/Status register
.equ SCS_SYST_RVR,0x14// Value to countdown from
.equ SCS_SYST_CVR,0x18// Current value
.equ SYSTICK_RELOAD_1MS, 63999 //1 msec at 64MHz ...
bl INIT_IO
bl INIT_TC
loop:
bl LED_ON
mov r0,#500
// bl DELAY
bl DELAYTC
bl LED_OFF
mov r0,#500
// bl DELAY
bl DELAYTC
b loop
__end: b __end
INIT_TC:
push {r0, r1, lr}
ldr r1, =SCS_BASE
ldr r0, =SYSTICK_RELOAD_1MS
str r0, [r1, #SCS_SYST_RVR]
mov r0, #0
str r0, [r1, #SCS_SYST_CVR]
mov r0, #0b101
str r0, [r1, #SCS_SYST_CSR]
pop {r0, r1, pc}
// Delay with internal timer based loop approx. r0 x ms
DELAYTC:
push {r1, r2, lr}
ldr r1, =SCS_BASE
LOOPTC: ldr r2, [r1, #SCS_SYST_CSR]
tst r2, #0x10000 // COUNT_FLAG=1?
beq LOOPTC
subs r0, r0, #1
bne LOOPTC
pop {r1, r2, pc}
// SysTick Timer definitions
.equ SCS_BASE,0xe000e000
.equ SCS_SYST_CSR,0x10// Control/Status register
.equ SCS_SYST_RVR,0x14// Value to countdown from
.equ SCS_SYST_CVR,0x18// Current value
.equ SYSTICK_RELOAD_1MS, 63999 //1 msec at 64MHz ...
bl INIT_IO
bl INIT_TC
loop:
bl LED_ON
mov r0,#500
// bl DELAY
bl DELAYTC
bl LED_OFF
mov r0,#500
// bl DELAY
bl DELAYTC
b loop
__end: b __end
INIT_TC:
push {r0, r1, lr}
ldr r1, =SCS_BASE
ldr r0, =SYSTICK_RELOAD_1MS
str r0, [r1, #SCS_SYST_RVR]
mov r0, #0
str r0, [r1, #SCS_SYST_CVR]
mov r0, #0b101
str r0, [r1, #SCS_SYST_CSR]
pop {r0, r1, pc}
// Delay with internal timer based loop approx. r0 x ms
DELAYTC:
push {r1, r2, lr}
ldr r1, =SCS_BASE
LOOPTC: ldr r2, [r1, #SCS_SYST_CSR]
tst r2, #0x10000 // COUNT_FLAG=1?
beq LOOPTC
subs r0, r0, #1
bne LOOPTC
pop {r1, r2, pc}
Last modified: Monday, 11 December 2023, 12:03 PM