SAMD21G18 >> Assembly
LED
參考資訊:
1. pdf
2. sample
LED腳位(PA-17)
暫存器
配置方式
main.s
.cpu cortex-m0 .thumb .equiv PORT_BASE, 0x41004400 .equiv PORT_A, 0x00 .equiv PORT_DIR, 0x00 .equiv PORT_OUT, 0x10 .thumb_func .global _start _start: .word 0x20001000 .word reset .word hang .word hang .word hang .word hang .word hang .word hang .word hang .word hang .word hang .word hang .word hang .word hang .word hang .word hang .thumb_func reset: ldr r0, =PORT_BASE ldr r1, =(1 << 17) str r1, [r0, #(PORT_A + PORT_DIR)] ldr r2, =(1 << 17) 0: eor r1, r2 str r1, [r0, #(PORT_A + PORT_OUT)] ldr r3, =100000 1: sub r3, #1 cmp r3, #0 bne 1b b 0b .thumb_func hang: b . .end
main.ld
MEMORY { ram : ORIGIN = 0x00000000, LENGTH = 0x1000 } SECTIONS { .text : { *(.text*) } > ram .rodata : { *(.rodata*) } > ram .bss : { *(.bss*) } > ram }
Makefile
all: arm-none-eabi-as -mcpu=cortex-m0 -o main.o main.s arm-none-eabi-ld -T main.ld -o main.elf main.o arm-none-eabi-objcopy -O binary main.elf main.bin clean: rm -rf main.bin main.o main.elf
編譯
$ make arm-none-eabi-as -mcpu=cortex-m0 -o main.o main.s arm-none-eabi-ld -T main.ld -o main.elf main.o arm-none-eabi-objcopy -O binary main.elf main.bin
開發板連接SWD後,開啟J-Flash
選擇ATSAMD21G18
SWD 4000khz
Connect
連線成功
Ctrl+O載入main.bin,起始位址0x00
載入main.bin後
燒錄
燒錄完成
執行
執行狀態
完成