ARM7---数码管显示---0-F

//config.h

#ifndef __CONFIG_H
#define __CONFIG_H

#include 

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

typedef  unsigned char uint8;
typedef  signed    char    int8;
typedef  unsigned  short  uint16;
typedef  signed  short  int16;
typedef  unsigned  int  uint32;
typedef  signed  int   int32;
typedef  float  fp32;
typedef  double  fp64 ;


#define Fosc		11059200

#define Fcclk		(Fosc*4)

#define Fcco		(Fcclk*4)

#define Fpclk		(Fcclk/4)*1


#endif

//Text1.c

#include "config.h"

void DelayMs(uint8 ms);
void WriteData(uint8 const dat);

uint8 i=0;

//字符数组
uint8 const DisplayChar[]=
{
	0xc0,0xF9,0xA4,0xB0,0x99,             //0-4
    0x92,0x82,0xF8,0x80,0x90,              //5-9
    0x88,0x83,0xC6,0xA1,0x86,             //A,b,C,d,E,F
    0x8E
};

//主函数入口
int main()
{
	PINSEL0 &=0xffffc000; //低7位为IO功能
	IO0DIR = 0x7f;//全部为输出
	IO0CLR = 0x7f;//清零

	while(1)
	{
		WriteData(DisplayChar[i]);
	}
}


//延时函数
void DelayMs(uint8 ms)
{  uint32  i;
   for (;ms>0;ms--)
      for(i=0;i<50000;i++);
}

//写数据
void WriteData(uint8 const dat)
{
	IO0CLR = 0x7f;//清空
	IO0SET = dat;
	DelayMs(10);
	i++;
	if(i>15)
		i = 0;
}

//图片


你可能感兴趣的:(Arm7)