微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > ARM技术讨论 > 我初学arm,2440的板子。对led灯的关闭不是很理解,

我初学arm,2440的板子。对led灯的关闭不是很理解,

时间:10-02 整理:3721RD 点击:
.text
.global _start
_start:
b reset
ldr pc,_undefine_instructions
ldr pc,_software_interrupt
ldr pc,_prefetch_abort
ldr pc,_data_abort
ldr pc,_not_use
ldr pc,_interrput
ldr pc,_fast_interrput
_undefine_instructions: .word undefine_instructions
_software_interrupt: .word software_interrupt
_prefetch_abort: .word prefetch_abort
_data_abort: .word data_abort
_not_use: .word not_use
_interrput: .word interrput
_fast_interrput: .word fast_interrput
reset:
bl set_svc
bl disable_watchdog
bl disable_interrupt
bl disable_mmu
bl clock_init
bl memory_init
bl code_remove
bl stack_init
bl bss_init
ldr pc,=gboot_main @从这跳到c部分,并开启2,4led
undefine_instructions:
nop
software_interrupt:
nop
prefetch_abort:
nop
data_abort:
nop
not_use:
nop
interrput:
nop
fast_interrput:
nop
set_svc:
    mrs r0,cpsr
bic r0,r0,#0b11111
orr r0,r0,#0b11010011
msr cpsr,r0
mov pc,lr
disable_watchdog:
ldr r0,=0x53000000
bic r1,r1,#0b101
str r1,[r0]
mov pc,lr
disable_interrupt:
ldr r0,=0x4A000008
bic r1,r1,#0xffffffff
str r1,[r0]
mov pc,lr
disable_mmu:
mcr p15,0,r0,c7,c7,0
mrc p15,0,r0,c1,c0,0
bic r0,r0,#0b0101
mcr p15,0,r0,c1,c0,0
mov pc,lr
#define PLLCON_405MHZ ((127<<12)|(2<<4)|(1<<0))
clock_init:
ldr r0,=0x4c000014
mov r1,#0x5
str r1,[r0]
mrc p15,0,r0,c1,c0,0
orr r0,r0,#0xc0000000
mcr p15,0,r0,c1,c0,0
ldr r0,=0x4c000004
ldr r1,=PLLCON_405MHZ
str r1,[r0]
mov pc,lr
#define BWSCON_ADDR 0x48000000
memory_init:
ldr r0,=BWSCON_ADDR
add r1,r0,#13*4
adrl r2,memory_init_data
b cycle
cycle:
ldr r3,[r2],#4
str r3,[r0],#4
cmp r0,r1
ble cycle
mov pc,lr
memory_init_data:
.long 0x22000000
.long 0x00000700
.long 0x00000700
.long 0x00000700
.long 0x00000700
.long 0x00000700
.long 0x00000700
.long 0x00018001
.long 0x00018001
.long 0x008c04f5
.long 0x000000b1
.long 0x00000030
.long 0x00000030
code_remove:
ldr r0,=0x0
ldr r1,=0x30000000
add r2,r1,#1024*4
remove_cycle:
ldr r3,[r0],#4
str r3,[r1],#4
cmp r1,r2
ble remove_cycle
mov pc,lr

stack_init:
ldr sp,=0x34000000
mov pc,lr

bss_init:
ldr r0,=bss_start
ldr r1,=bss_end
cmp r0,r1
moveq pc,lr
bss_init_cycle:
mov r2,#0x0
str r2,[r0],#4
cmp r0,r1
ble bss_init_cycle
mov pc,lr

.global light_led
light_led:
ldr r0,=0x56000010
ldr r1,=0x15400
str r1,[r0]
ldr r0,=0X56000014
ldr r1,=0x15f
str r1,[r0]
ldr pc,=into_assembly @这里应该是101011111开启1,3led,而且应该关闭led2,4啊可是并没有关闭

//c语言部分
#define GPBCON (volatile unsigned long *)0x56000010
#define GPBDAT (volatile unsigned long *)0X56000014
#define GPBCON_A 0x56000010
#define GPBDAT_D 0X56000014
int gboot_main()
{
//汇编调用部分
*(GPBCON)=0x15400;
*(GPBDAT)=0xbf;010111111;//开启2,4led

//调用汇编
light_led();
return 0;
}
int into_assembly()
{
//嵌套
__asm__ volatile(
  "ldr r1,=0x15400\n"
  "str r1,[%0]\n"
  "ldr r1,=0x1bf\n"
  "str r1,[%1]\n"
  :
  :"r"(GPBCON_A),"r"(GPBDAT_D)
  :"r1"
);
return 0;
//为什么所有的led都被点亮了。我最后一次2440不是将其余的都设置为高电平了吗
}

这个你好是好好理解下二进制的规则】
高低电平

我对怎么关闭不知道。你可以给我说说关闭了led吗?

关闭led其实就是高低电平呀

代码没有用,给出原理图,看看电路如何,引脚分配如何才能说清除

应该对应电路是使用高电平还是低电平做为关闭状态吧

led未必电平为高才电亮,得看具体电路

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top