LPC17xx Software Framework Explained

From Embedded Systems Learning Academy
Jump to: navigation, search


  • Do not forget to read the Project Documentation by generating it using Doxygen


The following occurs when the LPC processor resets:

  1. Reset Vector is fetched to go to RESET Handler
  2. Reset Handler sets up Global Memory by copying from FLASH to RAM
  3. Reset Handler calls low_level_init();
    • low_level_init() sets up CPU speed according to sysConfig.h
    • low_level_init() sets up Flash Accelerator based on CPU Speed
    • low_level_init() sets up minimal UART0 Driver and prints out CPU speed
  4. Reset Handler calls high_level_init();
    • high_level_init() initializes SPI Flash and SD Card Signals
    • high_level_init() initializes Board Drivers (See next section)
    • high_level_init() sets up TIMER0 for delay functions and FreeRTOS run-time statistics
    • high_level_init() will setup 10ms timer interrupt (RIT) for sd_timerproc()
    • high_level_init() attempts to move logfiles from SPI Flash to SD Card (See logger section)
    • high_level_init() initializes all Board IO such as temperature and IR sensor.
  5. Reset Handler calls your main();

Pre-Configured Drivers & Devices

The following drivers and devices are initialized by high_level_init() :


  • RTC
  • I2C #2
  • ADC0
  • SPI #1 (SD + SPI Flash)
  • SPI #2 (Nordic wireless)


  • Acceleration Sensor
  • Infrared Sensor
  • Light Sensor
  • Temperature Sensor
  • 7-Segment LED Display
  • LEDs
  • Switches


Logger functionality can be utilized to substitute printf because it may be difficult to analyze data while your program is running perhaps because of too much information being printed or maybe you don't have access to the terminal while your Board is running your program.

The Logger class is designed to log data onto a file in your SPI Flash. It can be easily modified to log to a file onto an SD Card as well. Unlike printf, it has the following features:

  • Logger will log the timestamp, filename, function name, and line number along with your message.
  • Logger will log messages classified under INFO, WARNING, and ERROR
    If the log file is opened in Excel, you can easily filter the message types
  • Logger size is configurable, it will only flush data onto the log-file if the buffer becomes full.

Logger Behavior

  • Logger is designed to write a file onto the SPI Flash Memory as filename: "log.csv"
  • Upon the Board boot-up, if an SD Card is present and log.csv file is present in SPI Flash, it will move this file to your SD Card such that new logs will start over in a new file in the SPI Flash Memory.


LOG_WARN("Did not expect this"); may log something like this:

   1200, WARN, my_file.cpp, my_function(), 123, Did not expect this

Practical Example

void sensor_task(void* p)
    while(1) {
        int sensor_value = get_sensor_value();
        if(0 == sensor_value) {
             LOG_WARN("Zero Sensor Value");
        if(sensor_value < 0) {