数码管部分 电路原理图:
其间TRS 和TMS运用了JTAG口,所以在调试的时分不能运用一般IO功用,需求程序烧写进入后,撤销JTAG形式,才干正常作业。
源程序:
/**************ARM7(LPC2103)操练程序**************************/
/*************************************************************/
/*****File Function : 数码管显现 *****/
/*****Program Author : ClimberWin *****/
/*****MCU : LPC2103F 外部12M晶振 *****/
/*****Compile Date : 2010/04/01 *****/
/*****Edition Info : V1.0 *****/
/*************************************************************/
//编译环境 KEIL for ARM
//数据接口 P0.10-P0.17
//选通端 P0.25 P0.26 P0.27 P0.28
//蜂鸣器 P0.21
//注:数码管运用到JTAG引脚,所以运转时分需求JTAG不使能才干做一般IO处理。否则只能2个数码管选通
#include
#include
#define uint unsigned int
#define uchar unsigned char
/**************ARM7(LPC2103)操练程序**************************/
/*************************************************************/
/*****File Function : 数码管显现 *****/
/*****Program Author : ClimberWin *****/
/*****MCU : LPC2103F 外部12M晶振 *****/
/*****Compile Date : 2010/04/01 *****/
/*****Edition Info : V1.0 *****/
/*************************************************************/
//编译环境 KEIL for ARM
//数据接口 P0.10-P0.17
//选通端 P0.25 P0.26 P0.27 P0.28
//蜂鸣器 P0.21
//注:数码管运用到JTAG引脚,所以运转时分需求JTAG不使能才干做一般IO处理。否则只能2个数码管选通
#include
#include
#define uint unsigned int
#define uchar unsigned char
//#define speak (1<<21) //蜂鸣器引脚界说
#define COM1 (1<<25) //界说数码管1的选通引脚
#define COM2 (1<<26) //界说数码管2的选通引脚
#define COM3 (1<<27) //界说数码管3的选通引脚
#define COM4 (1<<28) //界说数码管4的选通引脚
#define COM1 (1<<25) //界说数码管1的选通引脚
#define COM2 (1<<26) //界说数码管2的选通引脚
#define COM3 (1<<27) //界说数码管3的选通引脚
#define COM4 (1<<28) //界说数码管4的选通引脚
void delayms(unsigned int count);//延时程序
void led_display(void);//显现程序
void led_display(void);//显现程序
uchar LED_DATA[16]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
/*************延时程序***************/
void delayms(unsigned int count)
{
unsigned int i,j;
for(i=0;i for(j=0;j<1000;j++);
}
void delayms(unsigned int count)
{
unsigned int i,j;
for(i=0;i
}
void led_display(void)
{
float led_data;
IO0CLR=0xffffffff;
led_data=LED_DATA[4]<<10;
IO0SET=led_data;
IO0CLR=COM1;
IO0SET=COM2;
IO0SET=COM3;
IO0SET=COM4;
delayms(50);
{
float led_data;
IO0CLR=0xffffffff;
led_data=LED_DATA[4]<<10;
IO0SET=led_data;
IO0CLR=COM1;
IO0SET=COM2;
IO0SET=COM3;
IO0SET=COM4;
delayms(50);
IO0CLR=0xffffffff;
led_data=LED_DATA[3]<<10;
IO0SET=led_data;
IO0CLR=COM2;
IO0SET=COM1;
IO0SET=COM3;
IO0SET=COM4;
delayms(50);
led_data=LED_DATA[3]<<10;
IO0SET=led_data;
IO0CLR=COM2;
IO0SET=COM1;
IO0SET=COM3;
IO0SET=COM4;
delayms(50);
IO0CLR=0xffffffff;
led_data=LED_DATA[2]<<10;
IO0SET=led_data;
IO0CLR=COM3;
IO0SET=COM2;
IO0SET=COM1;
IO0SET=COM4;
delayms(50);
led_data=LED_DATA[2]<<10;
IO0SET=led_data;
IO0CLR=COM3;
IO0SET=COM2;
IO0SET=COM1;
IO0SET=COM4;
delayms(50);
IO0CLR=0xffffffff;
led_data=LED_DATA[1]<<10;
IO0SET=led_data;
IO0CLR=COM4;
IO0SET=COM1;
IO0SET=COM2;
IO0SET=COM3;
delayms(50);
}
led_data=LED_DATA[1]<<10;
IO0SET=led_data;
IO0CLR=COM4;
IO0SET=COM1;
IO0SET=COM2;
IO0SET=COM3;
delayms(50);
}
/////////////主程序///////////////////
void main(void)
{
void main(void)
{
PINSEL0 |= 0x00000000;
PINSEL1 |= 0x00000000;
PINSEL1 |= 0x00000000;
IO0DIR=0x1e03fc00; //装备P0.10-P0.17 P0.25 P0.26 P0.27 P0.28为输出
while(1)
{
led_display();
}
}
while(1)
{
led_display();
}
}