Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12409 Discussions

How to return value(s) in NIOS interrupt (ISR) function?

Altera_Forum
Honored Contributor II
1,621 Views

In the reference the return value is void, but how about I want to allocate a new variable in ISR and access it later in the main function? 

 

Thanks!
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
126 Views

You can use global variable which can be accessed in any function as well as in ISR routine.

Altera_Forum
Honored Contributor II
126 Views

 

--- Quote Start ---  

You can use global variable which can be accessed in any function as well as in ISR routine. 

--- Quote End ---  

 

 

However in my case, the variable is allocated dynamically, the size of the variable is unknown until ISR is triggered. Can I declare the global variable and then define its memory allocation later on?
Altera_Forum
Honored Contributor II
126 Views

You'd need a memory allocator that is callable from an ISR. 

Whether one exists depends on the operating system code you are running. 

It is unlikely that the malloc() in the BSP library is callable from ISRs. 

Maybe you can use a fixed size memory block as a software fifo.
Reply