嵌入式系统设计技术ARM实验(1~4)
Posted Wang_rush
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了嵌入式系统设计技术ARM实验(1~4)相关的知识,希望对你有一定的参考价值。
实验1&2:裸机下的led和蜂鸣器实验
DeepLed.c
#define GPL2CON (*(volatile unsigned long *) 0x11000100)
#define GPL2DAT (*(volatile unsigned long *) 0x11000104)
#define GPD0CON (*(volatile unsigned long *) 0x114000A0)
#define GPD0DAT (*(volatile unsigned long *) 0x114000A4)
#define GPK1CON (*(volatile unsigned long *) 0x11000060)
#define GPK1DAT (*(volatile unsigned long *) 0x11000064)
void delay(int r0)
volatile int count = r0;
while (count--)
;
void led_blink()
GPL2CON |= 0x00000001;
GPK1CON |= 0x00000010;
while(1)
GPL2DAT |= 1;
GPK1DAT |= 0;
delay(0x80000);
GPL2DAT |= 0;
GPK1DAT |= 0x2;
delay(0x80000);
void main()
GPD0CON |= 0x00000001;
while(1)
GPD0DAT |= 1;
delay(0x80000);
GPD0DAT |= 0;
delay(0x80000);
实验3&4:裸机条件下LED、蜂鸣器汇编综合设计实验
DeepLed.S
.text
.global _start
_start:
ldr r1, =0x114000A0 //把GPDOCON的地址赋给r1
ldr r0, [r1] //取GPDOCON的内容到寄存器r0
orr r0, r0, #0x1 //将r0最低位变成1
str r0, [r1] //r0的内容转移到GPD0CON
ldr r1, =0x11000100 //找到GPL2CON的地址
ldr r0, [r1]
orr r0, r0, #0x1 //只改变最低位
str r0, [r1] //r0寄存器的值传送到地址为r1的存储器中,把GPL2CON设置为0x1,GPL2作为输出
ldr r1, =0x11000060 //找到GPK1CON的地址
ldr r0, [r1]
orr r0, r0, #0x10 //只改变了倒数第二位
str r0, [r1] //把GPK1CON设置为0x10,GPD1作为输出
loop:
//GPD0DAT 0x01
ldr r1, =0x114000A4 //把GPD0DAT的地址赋给r1
ldr r0, [r1] //取GPD0DAT的内容到寄存器r0
orr r0, r0, #0x1 //将r0最低位变成1 蜂鸣器响
str r0, [r1] //r0的内容转移到GPD0DAT
//GPL2DAT 0x01
ldr r1, =0x11000104 //找到GPL2DAT的地址
ldr r0, [r1]
orr r0, r0, #0x1 //将GPL2DAT置一
str r0, [r1]
//将GPK1DAT 0x00
ldr r1, =0x11000064 //找到GPK1DAT的地址
ldr r0, [r1];
AND r0, r0, #0xfe //将GPK1DAT清零
str r0, [r1];
//延时
ldr r2, =0x7ffffff //设置延时时间
bl delay //延时
//GPL2DAT 0x00
ldr r1, =0x11000104 //找到GPL2DAT的地址
ldr r0, [r1]
AND r0, r0, #0xfe //将GPL2DAT清零
str r0, [r1];
//将GPK1DAT 0x01
ldr r1, =0x11000064 //找到GPK1DAT的地址
ldr r0, [r1]
orr r0,r0,#0x2
str r0, [r1]
//GPD0DAT 0x00;
ldr r1, =0x114000A4 //把GPD0DAT的地址赋给r1
ldr r0, [r1] //取GPD0DAT的内容到寄存器r0
AND r0, r0, #0xfe //把r0最低位变成0
str r0, [r1] //r0的内容转移到GPD0DAT
ldr r2, =0x7fffff //延时
bl delay
b loop
halt:
b halt
delay:
sub r2, r2, #0x01
cmp r2, #0x0
bne delay
mov pc , lr
Makefile 文件
DeepLed.bin: start.o DeepLed.o
arm-none-linux-gnueabi-ld -Ttext 0x0 -o DeepLed.elf $^
arm-none-linux-gnueabi-objcopy -O binary DeepLed.elf DeeLed.bin
arm-none-linux-gnueabi-objdump -D DeepLed.elf > DeepLed_elf.dis
%.o : %.S
arm-none-linux-gnueabi-gcc -o $@ $< -c -nostdlib
clean:
rm *.o *.elf *.bin *.dis -f
生成.bin文件
以上是关于嵌入式系统设计技术ARM实验(1~4)的主要内容,如果未能解决你的问题,请参考以下文章