Forum Discussion
Altera_Forum
Honored Contributor
19 years agoThank you scott for code!
I will try to dig your code but it looks too complicated (too big) for me and i don't understand this linker script http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif I can show you my code that I wrote for testing my Nios II custom made optical encoder perifery and that shows how mutch I lerned in coding( it's just basic steps in code writing for nios II procesor) I used this Altera debug client (learned form altera provided Lab exercises) to load in my Cyclone II dev.kit(for 150$) I also tried nios II IDE but I don't know how to compile it and how to make this assembly code (I suppose this linker script is needed there am i right? http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/unsure.gif ) here is my encoder perifery test code that works fine http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif And in this week I added Interupt pin (avalon slave with interupt vector) and I need some extremly simple code to test it..include "nios_macros.s"
.equ enkoder, 0x00001800
.equ LEDG, 0x00001820# Cyclone II dev.kit Green LEDS
.equ LEDR, 0x00001810# Cyclone II dev.kit RED LEDS
/*enkoder register addres:
0 Speed
4 Caunter
8 Status*/
.global _start
_start:
movia r2, enkoder
movia r3, LEDR
movia r5, LEDG
loop:
ldwio r6, 4(r2) # Read Caunter register caunt value
stbio r6, 0(r3) # Show caunter value by RED leds
nop
ldwio r6, 0(r2) //Read speed value
stbio r6, 0(r5) // show speed value by GREEN Leds
nop
br loop # infinit loop :) Previously on AVR 8bit procesors I didn't use eny linker scripts I codes in siple assembly but there was lot of simple examples also about interupts http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif so I lerned wery fast, but now lerning Nios II is more dificult becose there are just few Lab exercises and they are incomplete (this first code I puted was from Lab exercise 4 and it is incomplete)