Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

9.6.2. Registering an Instruction-Related Exception Handler

The HAL API function alt_instruction_exception_register() registers a single instruction-related exception handler.

The function prototype is as follows:

alt_instruction_exception_register ( 
 alt_exception_result (*handler)
 ( alt_exception_cause, alt_u32, alt_u32 ));

The handler argument is a pointer to the instruction-related exception handler.

To use alt_instruction_exception_register(), include the following header file:

#include "sys/alt_exceptions.h"

Note: The hal.enable_instruction_related_exceptions_api setting must be enabled in the BSP in order for you to register an instruction-related exception handler.

For more information, refer to “Settings Managed by the Software Build Tools” in the " Nios® II Software Build Tools Reference" section.

Note: Register the instruction-related exception handler as early as possible in function main(). This allows you to handle abnormal condition during startup. You register an exception handler from the alt_main() function.

For more information about alt_main(), refer to “Boot Sequence and Entry Point” in the "Developing Programs Using the Hardware Abstraction Layer" section.