LPC1347 Hardware Part 2

LPC1347_MinimalThe minimum hardware to build the development board is shown here. The reset circuit is very important to the design because it allows you to either reset the processor or start the boot loader using a single button. A brief press of the button causes a reset while a longer 1 second press engages the boot loader. When the boot loader starts the LPC1347 looks like a USB Flash memory stick which you can erase and copy a new program to; after a reset your new code executes immediately.

The second detail that is important to note about the design is that you need access to the USB port in order to communicate with the chip. The USB interface allows code to be downloaded as well it can be used as a USB serial port, and finally the USB VBUS lead can power your development board.

If you opt for an LPCXpresso board you will need to add the USB soft-connect and reset circuit yourself.

Hello World

The whole point of creating this library was to simplify getting started using the LPC1347. To create a new project:

  1. Create a project folder called “HelloWorld”
  2. Copy the “makefile” to the “HelloWorld” folder
  3. Create a “src” and “inc” folder in the “HelloWorld” folder
  4. Open Programmers Notepad and click the “File->New->project” button to make a project called “Hello” in the “HelloWorld” directory. Click OK.
  5. Open a new “File->New->C/C++” file in Programmers Notepad and save it as “main.c” in the “HelloWorld/src” directory
  6. Copy the following code to “main.c” and save
#include "../../library/libDNCLABS.h"

int main (void) {
	SystemInit();
	SystemCoreClockUpdate();
	SysTick_Config (SystemCoreClock/1000);	//1kHz (1ms)

	Comport_Init(CDC,9600);                 //Setup communication port
	while (1) {                             // Loop forever
		putchar(getchar());
		printf("Hello World\n");
	}
}
  1. Right click the “Hello” project icon in the Projects frame of Programmers Notepad and then select “Add New folder” and call it “src”
  2. Right click the “Hello” project icon in the Projects frame of Programmers Notepad and then select “Add New folder” and call it “inc”
  3. Right click the “src” project icon in the Projects frame of Programmers Notepad and then select “Add files” selecting the “main.c” file you just created.
  4. Right click the “Hello” project icon in the Projects frame of Programmers Notepad and then select “Add files” selecting the “makefile”.
  5. Compile the code by pressing F5 in Programmers Notepad

 

arm-none-eabi-g++ -W -Wall -I  -fno-common -Os -std=gnu++98  -mcpu=cortex-m3 -mthumb  -ffunction-sections -fdata-sections -g3 -D__USE_CMSIS=CMSISv2p00_LPC13xx -I../CDC_library/inc/ -I../CMSISv2p00_LPC13xx/inc -I../library/ -c src/main.c -o src/main.o
arm-none-eabi-ld -Map=main.map -T../library/LPC13xx.ld --gc-sections -nodefaultlibs -nostartfiles  src/main.o  ../library/libDNCLABS.a -o main.elf
arm-none-eabi-size main.elf
   text	   data	    bss	    dec	    hex	filename
   4052	      4	   2456	   6512	   1970	main.elf
arm-none-eabi-objdump -h -S main.elf > main.lss
arm-none-eabi-objcopy -R .stack -O ihex main.elf main.hex
arm-none-eabi-objcopy -O binary -j .text -j .data main.elf main.bin
checksum -p LPC1347 -d main.bin
Created checksum 0xefffdab6 at offset 0x1c in file main.bin

 

  1. Press and hold the reset button for 1 second.
  2. Press F7 to download the code to the LPC1347.
  3. Press the reset button briefly and it should enumerate as a COM port.

Final Note

The library size that gets linked into your code varies depending on the features you select. The minimum code impact is ~4K; using formatted printf() statements adds ~10K to the code size. If you are use to small AVR and PIC’s you might find this concerning however the LPC1347 has 64K bytes of Flash so there is still plenty of room for you own code.

Leave a Reply

Your email address will not be published. Required fields are marked *