參考資料:
https://www.keil.com/dd/docs/datashts/philips/user_manual_lpc2101_2102_2103.pdf
暫存器

main.s
.equ IODIR, 0xe0028008
.equ IOCLR, 0xe002800c
.equ IOSET, 0xe0028004
.text
.align 2
.global _start
_start: b reset
_undef: b .
_swi: b .
_pabort: b .
_dabort: b .
_reserved: b .
_irq: b .
_fiq: b .
reset:
ldr r0, =IODIR
ldr r1, =(1 << 22)
str r1, [r0]
loop:
ldr r0, =IOCLR
ldr r1, =(1 << 22)
str r1, [r0]
ldr r4, =50000
1:
nop
subs r4, r4, #1
bne 1b
ldr r0, =IOSET
ldr r1, =(1 << 22)
str r1, [r0]
ldr r4, =50000
1:
nop
subs r4, r4, #1
bne 1b
b loop
.end
main.ld
MEMORY {
FLASH : ORIGIN = 0, LENGTH = 32K
}
SECTIONS {
text : {
*(.text)
} > FLASH
}
Makefile
all: arm-none-eabi-as -mcpu=arm7 -o main.o main.s arm-none-eabi-ld -T main.ld -o main.elf main.o arm-none-eabi-objcopy -O ihex main.elf main.ihx packihx main.ihx > main.hex flash: sudo lpc21isp -wipe -control -verify -debug2 ./main.hex /dev/ttyUSB0 9600 12000 clean: rm -rf main.ihx main.hex main.o main.elf
編譯、燒錄
$ make
arm-none-eabi-as -ggdb -mcpu=arm7 -o main.o main.s
arm-none-eabi-ld -T main.ld -o main.elf main.o
arm-none-eabi-objcopy -O ihex main.elf main.ihx
packihx main.ihx > main.hex
packihx: read 10 lines, wrote 10: OK.
$ make flash
sudo lpc21isp -wipe -control -verify -debug2 ./main.hex /dev/ttyUSB0 9600 12000
Verify after copy RAM to Flash.
lpc21isp version 1.97
File ./main.hex:
loaded...
converted to binary format...
image size : 136
Image size : 136
Synchronizing (ESC to abort). OK
Read bootcode version: 21
2
Read part ID: LPC2103, 32 kiB FLASH / 8 kiB SRAM (0x0004FF11)
Will start programming at Sector 1 if possible, and conclude with Sector 0 to ensure that checksum is written last.
Wiping Device. OK
Sector 0: ......
Download Finished and Verified correct... taking 1 seconds
Now launching the brand new code
完成
