Integrate timer module in top and add test program

This commit is contained in:
2022-11-06 17:45:31 +01:00
parent dd4ca39450
commit 1562d668a1
3 changed files with 124 additions and 1 deletions

56
programs/timer_test.prog Normal file
View File

@@ -0,0 +1,56 @@
reset:
br always >main
nop
hardfault:
reti
nop
memfault:
reti
nop
timer_interrupt:
br >timer_interrupt_handler
nop
.align
led_addr: .word 0x000F0000
timer_counter_addr: .word 0x000F0008
timer_status_addr: .word 0x000F000C
dmem_start_addr: .word 0x00000400
dmem_end_addr: .word 0x000004FF
priority_mask: .word 0xFFFFFF03
main:
// Initialize stack pointer to the end of the data memory
ldr r12, >dmem_end_addr
// Set runtime priority
ldr r0, >priority_mask
and r14, r0, r14
ldr r0,>led_addr // LED addr
ldr r1,>timer_status_addr // Timer addr
// Set some LEDs
clr r2
addi r2, 0x5A
st08 r0, r2
// Enable the timer...
clr r2
addi r2, 0x1 // enable bit set
st08 r1, r2
loop:
call >loop
nop
timer_interrupt_handler:
// Set LEDs to indicate we reached the timer interrupt
clr r2
addi r2, -1
st08 r0, r2
reti