The goal of this lab was to learn:
• How to enable the interrupt subsystem to allow hardware interrupts to interrupt software execution
• Create an interrupt service routine to handle the hardware interrupt
An interrupt handler, also known as an Interrupt Service Routine (ISR), is a callback subroutine in microcontroller firmware, operating system, or device driver whose execution is triggered by the reception of a hardware interrupt. Interrupt handlers have a multitude of functions, which vary based on the reason the interrupt was generated and the speed at which the interrupt handler completes its task.
An interrupt handler is a low-level counterpart of event handlers. These handlers are typically initiated by hardware interrupts and are used for servicing hardware devices and transitions between protected modes of operation such as system calls.
In this lab we will perform steps to import a known good code base to access a piece of custom hardware built into the system. This hardware will control the back light on the LCD mini click allowing the backlight intensity to be increased and decreased. From that point, we will modify the application code to respond to an interrupt generated by the custom hardware platform when an incorrect PWM value is written to the PWM controller.
This was the first lab I did that utilized the Click Mezzanine and Click boards. It used the LCD Mini Click and the lab software was used to change its brightness of the LCD back lighting, showcasing an interrupt service routine when an invalid value is entered.
In the first experiment of the lab I walked through a sample application that allowed me to control the backlight brightness of the LCD. The brightness was select via a keyboard entry using the serial terminal.
The second experiment in the lab involved adding interrupt support to the application imported and used in the first experiment. Acheck was also added to prevent a user from entering a value that excedded the allowed range. The follwoing api calls used to support Interrupts were highlighted:
int XScuGic_CfgInitialize
(XScuGic *InstancePtr, XScuGic_Config *ConfigPtr, u32 EffectiveAddr)
• CfgInitialize a specific interrupt controller instance/driver.
• The function initializes the field of XscuGic structure and the initial vector table with stub function calls.
• All interrupt sources are disabled when initialization occurs.
int XScuGic_Connect
(XScuGic *InstancePtr, u32 Int_Id, Xil_InterruptHandler Handler, void *CallBackRef)
• Makes the connection between the Int_Id of the interrupt source and the associated handler that is to run when the interrupt is recognized.
void XScuGic_Enable
(XScuGic *InstancePtr, u32 Int_Id)
• Enables the interrupt source provided as the argument Int_Id.
• Any pending interrupt condition for the specified Int_Id will occur after this function is called.
void XScuGic_SetPriorityTriggerType
(XScuGic *InstancePtr, u32 Int_Id, u8 Priority, u8 Trigger)
• Sets the interrupt priority and trigger type for the specified IRQ source.
XScuGic_Config * XScuGic_LookupConfig (u16 DeviceId)
• Looks up the device configuration based on the unique device ID.
• A table contains the configuration info for each device in the system.
void XScuGic_InterruptHandler (XScuGic *InstancePtr)
• This function is the primary interrupt handler for the driver.
• It must be connected to the interrupt source such that it is called when an interrupt of the interrupt controller is active.
• It will resolve which interrupts are active and enabled and call the appropriate interrupt handler.