LPC17xx Software Framework Explained

From Embedded Systems Learning Academy
Revision as of 01:00, 1 September 2012 by Preet (talk | contribs) (Startup)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Notes

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


Startup

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 lowLevelInitialize();
    • lowLevelInitialize() sets up CPU speed according to sysConfig.h
    • lowLevelInitialize() sets up Flash Accelerator based on CPU Speed
    • lowLevelInitialize() sets up minimal UART0 Driver and prints out CPU speed
  4. Reset Handler calls highLevelInitialize();
    • highLevelInitialize() initializes SPI Flash and SD Card Signals
    • highLevelInitialize() initializes Board Drivers (See next section)
    • highLevelInitialize() sets up TIMER0 for delay functions and FreeRTOS run-time statistics
    • highLevelInitialize() will setup 10ms timer interrupt (RIT) for sd_timerproc()
    • highLevelInitialize() attempts to move logfiles from SPI Flash to SD Card (See logger section)
    • highLevelInitialize() 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 highLevelInitialize() :

Drivers:

  • RTC
  • I2C #2
  • ADC0
  • SPI #1

Devices:

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


Logger

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.

Example

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

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