LPC2103學(xué)習(xí)板-數(shù)碼管顯示
數(shù)碼管部分 電路原理圖:
本文引用地址:http://m.butianyuan.cn/article/201611/316023.htm其中TRS 和TMS使用了JTAG口,所以在調(diào)試的時候不能使用普通IO功能,需要程序燒寫進入后,取消JTAG模式,才能正常工作。
源程序:
/**************ARM7(LPC2103)練習(xí)程序**************************/
/*************************************************************/
/*****File Function : 數(shù)碼管顯示 *****/
/*****Program Author : ClimberWin *****/
/*****MCU : LPC2103F 外部12M晶振 *****/
/*****Compile Date : 2010/04/01 *****/
/*****Edition Info : V1.0 *****/
/*************************************************************/
//編譯環(huán)境 KEIL for ARM
//數(shù)據(jù)接口 P0.10-P0.17
//選通端 P0.25 P0.26 P0.27 P0.28
//蜂鳴器 P0.21
//注:數(shù)碼管使用到JTAG引腳,所以運行時候需要JTAG不使能才能做普通IO處理。不然只能2個數(shù)碼管選通
#include
#include
#define uint unsigned int
#define uchar unsigned char
/**************ARM7(LPC2103)練習(xí)程序**************************/
/*************************************************************/
/*****File Function : 數(shù)碼管顯示 *****/
/*****Program Author : ClimberWin *****/
/*****MCU : LPC2103F 外部12M晶振 *****/
/*****Compile Date : 2010/04/01 *****/
/*****Edition Info : V1.0 *****/
/*************************************************************/
//編譯環(huán)境 KEIL for ARM
//數(shù)據(jù)接口 P0.10-P0.17
//選通端 P0.25 P0.26 P0.27 P0.28
//蜂鳴器 P0.21
//注:數(shù)碼管使用到JTAG引腳,所以運行時候需要JTAG不使能才能做普通IO處理。不然只能2個數(shù)碼管選通
#include
#include
#define uint unsigned int
#define uchar unsigned char
//#define speak (1<<21) //蜂鳴器引腳定義
#define COM1 (1<<25) //定義數(shù)碼管1的選通引腳
#define COM2 (1<<26) //定義數(shù)碼管2的選通引腳
#define COM3 (1<<27) //定義數(shù)碼管3的選通引腳
#define COM4 (1<<28) //定義數(shù)碼管4的選通引腳
void delayms(unsigned int count);//延時程序
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();
}
}
評論