-
Notifications
You must be signed in to change notification settings - Fork 16
MCU Info Page: LPC1768
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.
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 |
|
|
*"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.
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.
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.
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.
As a legacy of the original Mbed design, this board has a unique feature that is no longer found on any other Mbed targets:
One of the 32-bit timers, TIM3, is used to implement the Mbed us_ticker. The other three timers are available for application usage.