Hallo Forum,
ich hab eine Frage. In Qsys habe ich den timer0 für den Nios 2
ausgewählt und 2 micro Sekunden eingestellt. Muss ich noch die
Funktionen IOWR_ALTERA_AVALON_TIMER_PERIODH() und
IOWR_ALTERA_AVALON_TIMER_PERIODL() für die Periodendauer benutzen? Oder
wird es automatisch durch die defines eingestellt?
So initialisiere ich den Timer:
1 | static void init_interrupt()
|
2 | {
|
3 |
|
4 | IOWR_ALTERA_AVALON_TIMER_STATUS(TIMER_0_BASE, 0);
|
5 | /* Register the interrupt handler. */
|
6 |
|
7 | alt_ic_isr_register(TIMER_0_IRQ_INTERRUPT_CONTROLLER_ID, TIMER_0_IRQ, timer0_isr, NULL, 0x0);
|
8 |
|
9 | }
|
So starte ich den Timer:
1 | static void start_timer0()
|
2 | {
|
3 |
|
4 | IOWR_ALTERA_AVALON_TIMER_CONTROL(TIMER_0_BASE, ALTERA_AVALON_TIMER_CONTROL_CONT_MSK | ALTERA_AVALON_TIMER_CONTROL_START_MSK | ALTERA_AVALON_TIMER_CONTROL_ITO_MSK);
|
5 |
|
6 | }
|
Und das sind die erstellten defines von Qsys in system.h
1 | /*
|
2 | * timer_0 configuration
|
3 | *
|
4 | */
|
5 |
|
6 | #define ALT_MODULE_CLASS_timer_0 altera_avalon_timer
|
7 | #define TIMER_0_ALWAYS_RUN 0
|
8 | #define TIMER_0_BASE 0x21020
|
9 | #define TIMER_0_COUNTER_SIZE 32
|
10 | #define TIMER_0_FIXED_PERIOD 0
|
11 | #define TIMER_0_FREQ 50000000
|
12 | #define TIMER_0_IRQ 5
|
13 | #define TIMER_0_IRQ_INTERRUPT_CONTROLLER_ID 0
|
14 | #define TIMER_0_LOAD_VALUE 99
|
15 | #define TIMER_0_MULT 1.0E-6
|
16 | #define TIMER_0_NAME "/dev/timer_0"
|
17 | #define TIMER_0_PERIOD 2
|
18 | #define TIMER_0_PERIOD_UNITS "us"
|
19 | #define TIMER_0_RESET_OUTPUT 0
|
20 | #define TIMER_0_SNAPSHOT 1
|
21 | #define TIMER_0_SPAN 32
|
22 | #define TIMER_0_TICKS_PER_SEC 500000
|
23 | #define TIMER_0_TIMEOUT_PULSE_OUTPUT 0
|
24 | #define TIMER_0_TYPE "altera_avalon_timer"
|
Vielen Dank für weitere Infos:-)