Skip to content

MCU Info Page: LPC1768

Jamie Smith edited this page Sep 13, 2022 · 15 revisions

LPC1768 MCU Overview

LPC1768 board

The LPC1768 was the very first MCU to receive support from Mbed back in 2009, and it's one of the only early MCUs that's still supported in the latest Mbed version. While it might be getting a little long in the tooth, with fairly high power consumption and small RAM compared to its modern competitors, it's still a capable chip with a large array of peripherals. Not to mention, it has a significant base of educational users who rely on the Mbed LPC1768 dev board for their courses and projects. Here's hoping we can keep this venerable chip supported for a long time coming!

Note: Confusingly, the LPC1768 MCU's dev board is also called the LPC1768. This seems to be an early naming standard that was later dropped. On this page I'll say "the dev board" when I specifically mean the LPC1768 PCB; otherwise I mean the microcontroller itself.

Feature Overview

CPU Flash/Code Memory RAM Communication Peripherals Other Features
Cortex-M3, up to 100MHz
(clocked at 96MHz on the dev board)
Total: 512 kiB
Available to user:* 481.5 kiB
Total: 32 kiB (SRAM) + 16 kiB (AHBSRAM0) + 16 kiB (AHBSRAM1)
Available to user:* 19.1kiB
See note about memory banks below
  • 3x I2C (2 pinned out on dev board)
  • 4x UART (3 pinned out on dev board), one has hardware flow control
  • 2x SPI
  • 1x CAN
  • 1x USB
  • 1x Ethernet
  • 1x DAC (AnalogOut)
  • 1x ADC (AnalogIn), 200kHz, 8 multiplexed inputs
  • 6x PWM outputs (must share a common pulse period)
  • RTC
  • 4x 32-bit hardware timers
  • DMA (not supported by Mbed, but can be used through the MODDMA library)

*"Available to user" subtracts both regions of memory unusable by default Mbed OS projects and the baseline memory used by a minimal build of Mbed OS.

A note about LPC1768 memory banks

The LPC1768 divides its RAM into three banks: main SRAM, AHBSRAM0, and AHBSRAM1. The AHBSRAM banks are optimized for use with DMA, but are also usable as standard RAM. However, they are not contiguous with the first one, so the GNU linker is not able to automatically place items in these memory banks. Thus, only the first 32k bank is available to naive code.

To make use of these memory banks, you need to manually place items in them using an attribute declaration. If you have code like this:

SomeLargeObject obj;

change it to:

SomeLargeObject obj __attribute__((section("AHBSRAM0")));

This will move the object into the ABHSRAM0 bank. This can be used on both global variables and static variables inside functions.

Additionally, when Ethernet connectivity is used, Mbed automatically places the networking buffers into AHBSRAM1.

Configuring Clocking

Mbed OS currently uses a fixed clocking configuration for the LPC1768. A 12Mhz input clock is required, either by connecting a crystal between XTAL1 and XTAL2, or by connecting an external 1.8V oscillator to XTAL1. See the electrical datasheet section 15.2 for details.

Additionally, a 32.768kHz crystal can be connected to the RTCX1 and RTCX2 pins to provide a clock source to the RTC. However, this is optional, and the crystal is not even powered up until the RTC is used in code.

Dev Board Firmware Update (PLEASE READ)

As of 2022, new LPC1768 dev boards are still being shipped with very old firmware on their interface chips. Not only does this firmware not support debugging, it also makes thread sleeps run for an incorrect amount of time! You will find that your MCU sleeps for 10ms when you tell it to sleep for 1ms! No, I don't know why this happens, but I do know how to fix it.

To update the firmware, simply download this file and save it onto the LPC1768 dev board's USB drive. Then, unplug the USB connection to turn off the power and plug it back in again. Leave the board alone for a few seconds, and it should flash the firmware and boot like normal.

More details on the interface firmware here.

Semihosting and the LocalFileSystem

As a legacy of the original Mbed design, this board has a unique feature that is no longer found on any other Mbed targets:

Other Notes

TIM3 Usage

One of the 32-bit timers, TIM3, is used to implement the Mbed us_ticker. The other three timers are available for application usage.

Semihosting

Datasheets

  • Mbed dev board schematic (note, this is an HTTP download, so you may have to copy the URL to a new tab to get it to download)