Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12606 Discussions

Code for handling a simple ISR

Altera_Forum
Honored Contributor II
1,029 Views

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?
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
288 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
288 Views

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.

0 Kudos
Reply