LPC17xx Memory Map & Interrupts

From Embedded Systems Learning Academy
Jump to: navigation, search

Memory Map

LPC Memory map can be accessed by using structures, but the "LPC17xx.h" file may be confusing at first to find your LPC registers. The memory map is accessed by structure names followed by structure members. Let's work through an example in which you are trying to find out how to access PINSEL0 mentioned in your LPC datasheet:

  • Open up "LPC17xx.h" (it is in Project/L0 folder)
  • Search for "PINSEL0"
    You will see that this is inside a struct called LPC_PINCON_TypeDef:
  • Now search for "LPC_PINCON_TypeDef" with a #define in the same line.
    You will see that LPC_PINCON is a pointer of this struct
  • You can now access PINSEL0 by :

At first this may get tedius, but once you get more experience, you won't open the LPC17xx.h file very often.


LPC_SC->PCONP |= (1 << 12);     // Power up ADC

Interrupts on Cortex M3 Core

Unlike the LPC12xx (ARM7) processors, the Cortex M3 core saves interrupt context automatically. Hence no interrupt attribute is needed and furthermore, function address doesn't need to be specified into any control registers since interrupt vector is fixed.

The easiest way to define an interrupt function is to:

  • Look up Interrupt Names in file L0/src/startup.cpp
    Look for declaration of a bunch of functions at this file with keyword ALIAS
    For example: UART0_IRQHandler();
  • Define this function in one of your source code files.
    Enclose in extern "C"{ } tags if you are defining the name in *.cpp file
    extern "C" is not needed if you are defining this in *.c file
  • Enable the Interrupt using CMS Interrupt API:


// Here is the Interrupt Function in a main.cpp file
extern "C"
    void UART0_IRQHandler()

// Enable Interrupt somewhere in your code: