Nios® V Processor Software Developer Handbook

ID 743810
Date 10/06/2025
Public
Document Table of Contents

9.3.5.4.3. Adding Custom Exception Handler

Once the polling mode is enabled in the JTAG UART following the instruction from the previous section, the following steps can help with seeing the cause of non-interrupt related exceptions like load or store misaligned, etc.

Add the following section to register this new exception handling function in the main() function, right above the code which causes the exception.
int main(void) {
    alt_instruction_exception_register (instr_exception_handler);  // Register custom instruction exception handler.
 
    printf("Hello world!\n");
    function_which_causes_the_exception();
   return 0;
}