Lab: Interrupts and Binary Semaphores


Learn how to create a single dynamic user defined interrupt service routine callback driver/library. Be sure to click through the hyperlinks provided in this article to learn the background knowledge before you jump into the assignment. You may re-use any existing code, such as the API from gpio.h header file.

This lab will utilize:

  • Semaphores
  • Lookup table structures and Function Pointers
    • You will allow the user to register their callbacks
    • Be sure to understand how function pointers work
  • Interrupts
    • LPC supports rising and falling edge interrupts on certain port pins
    • These port/pin interrupts are actually OR'd together and use a single CPU interrupt.
    • For the SJ1 board, it is: EINT3 interrupt.
    • On the SJ2 board, GPIO interrupts are handled by a dedicated GPIO interrupt (exception number 54)

Where to start
  • For Part 0, do the following
    • Read the LPC User Manual, particularly ALL information about Table 95: GPIO Interrupt
    • Browse the code, and fully absorb interrupt_vector_table.c and entry_point.c
  • For Part 1, first review the Semaphore Design pattern that will be utilized later


Port Interrupts

You will configure GPIO interrupts.  This is supported for Port0 and Port2 and the following registers are relevant. Note that there is a typo in the LPC user-manual as pointed by the orange notation below.


For extra reading material, you can take a look at Chapter 5: LPC408x/407x User Manual, and the Chapter 8 section 8.5.2 to understand more about the GPIO interrupt block diagram