Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

Code for handling a simple ISR

I made my file system, kernel, app and uploaded, this is the source:

# include "D:\Proyectos\Marzo\NIOS2ndTry\Krl\build\include\nios2_system.h"# include <stdio.h>

typedef unsigned char INT8U;# define NIOSTmr (np_timer *)na_high_res_timer # define pio ((np_pio *)na_led_pio)# define PIO pio->np_piodata

void TmrISR(void);

int main(void) {

(*NIOSTmr).np_timerperiodl = 0xB400;

(*NIOSTmr).np_timerperiodh = 0x04C4;

(*NIOSTmr).np_timercontrol = np_timercontrol_cont_mask |

np_timercontrol_start_mask |

np_timercontrol_ito_mask ;

nr_installuserisr(na_high_res_timer_irq, &TmrISR, 0);

while(1) {

}

return 0;

}

void TmrISR(void) {

static INT8U Ctr;

(*NIOSTmr).np_timerstatus &= ~np_timerstatus_to_mask;

PIO = Ctr++;

printf("%d seconds\n", Ctr);

}

but when i make my application, and try to run it, the system resets itself.

Any suggestions, corrections of the malfunctioning?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You can not use altera hal for interrupt service in uClinux. Read ch10 Interrupt Handling on the book "Linux device drivers 3rd ed.".

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    you are tryin to implement ISRs in a user-land application, and as far as I know, I don&#39;t think you can do this. All interrupts must be built into the kernel as a driver, correct? you need to write an actual driver, not a user application.