mini2440 led跑马灯+ 按键控制

 1、准备工作

开发工具:ADS 1.2

调试工具:mini 2440 开发板一个

调试环境:H-JTAG 1.1

2、目标

2.1、实现mini 2440 按键1-4控制4个灯

每个按键按下时对应灯亮

2.2、实现mini 2440 按键5控制跑马灯

当按下按钮5时,跑马灯程序运行

2.3、实现mini 2440 按键6控制全灭全亮交替出现

当按下按键6时,led灯全闪烁

2.4、实现按键的去抖动

只有当按键按下,而不是挨着时就认为按键被触发

3、代码编写

3.1、端口准备(def.h)

#ifndef __DEF__

//参照mini 2440 手册,灯和按键模块
#define __DEF__

#define rGPBCON (*((volatile unsigned *)0x56000010))   
#define rGPBDATA (*((volatile unsigned *)0x56000014))   

#define rGPGCON (*((volatile unsigned *)0x56000060))  
#define rGPGDATA (*((volatile unsigned *)0x56000064)) 

#endif

3.2、引导代码(marquee_init.s)

 AREA init, CODE, READONLY
 
start    ldr sp,=4096
            import main
            bl main
            end

3.3、主程序(marquee_main.c)

#include "def.h"

void desplay(unsigned int n)
{
	while(n-- > 0);
}

//控制灯亮n->[5,8]
void light(short unsigned n)
{
	rGPBDATA &=(~(1<[5,8]
void light_off(short unsigned n)
{
	rGPBDATA |=(1<


 

4、环境配置

4.1、ADS 1.2

DebugRel Settings:

Target Settings:

Post-linker:ARM fromELF

ARM Assembler:

Target :

Architecture or Processor:

ARM920T

ARM C Compiler:

Target  and Source:

Architecture or Processor:

ARM920T

ARM Linker:

Output:

Linktype:

Simple

Simple image:

RO Base:ox30000000

Layout:

Object/Symbol:

marquee_init.o

Section:

init

4.2、H-JTAG

Settings:

USB/LPT Selection:

LPT

LPT JTAG Settings:

User Defined:

TMS:

Pin4 D2

TCK:

Pin2 D0

TDI:

Pin3 D1

TD0

Pin11 Busy

nTRST:

NO TAP RST

nSRST:

NO TAP RST

Target Settings:

Processor Delect:

ARM920T

Target Endian:

little Endian

 

你可能感兴趣的:(mini2440 led跑马灯+ 按键控制)