Reputation: 39
I am trying to design a program that the on board LEDs flash every second. So all LEDs on FPGA board on for 1 sec and then off for 1 sec. I was recommended to use interval timer or interrupt service routine to measure the period of one second.
DE-10 NANO
I came up with this solution but does not work. I am not asking you to do my homework, just looking for some advice/tips.
Thanks in advance.
Here is my code so far :
.include "address_map_arm.s"
.text /* executable code follows */
.global _start
_start:
LDR R2, =LED_BASE // base address of LED lights
LDR R3, =LED_BASE // LED base address
LDR R0, =TIMER_BASE // base address
LDR R6, [R2] // load pattern for LED displays
STR R6, [R3] // store to LEDs
DISPLAY:
STR R6, [R2] // load SW switches
timer:
MOV R0, #0 // used to stop the timer
STR R1, [R0, #0x8] // write to timer control register
LDR R1, =100000000 // period = 1/(100 MHz) x (100 x 10^6)
// = 1 sec
STR R1, [R0] // write to timer load register
MOV R1, #0b111 // int mask = 1, mode = 1, enable = 1
STR R1, [R0, #0x8] // write to timer control register
BX LR
RESET:
B DISPLAY
Upvotes: 1
Views: 2471
Reputation: 648
It looks like your intention is to read the state of the switches and then display that pattern on the LEDs.
However, if you look at your first two instructions you are loading the base address for the LEDs twice and you never load the base address for the switches. So what your code actually does is read the state of the LEDs and then write that back out to the LEDs. Even if the code is running properly, you will never see any change in the LEDs.
Furthermore, to get the state of the switches you need to use an LDR
instead of an STR
.
Upvotes: 2