倒计时.c

来自「针对PP2132V1开发的详细的实验教程」· C语言 代码 · 共 49 行

C
49
字号
/***********************************
功能:采用P0口实现60秒倒计时;
接线:P0.0~P0.7口接低位数码管a~h;
      P0.8~P0.15口接高位数码管a~h;
      该程序对应共阳极数码管;
      程序采用延时实现。
目的:更深入掌握ARM的GPIO口的使用
作者:刘启明
更新:2008年1月20日
***********************************/

#include "IOLPC2132.h"

unsigned char count;
unsigned char Tab[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,
                     0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71};

void delay()
{
  unsigned int i,j;
  for(i=0;i<2000;i++)
    for(j=0;j<200;j++);
}

void main()
{
  PINSEL0=0x00000000;
  IO0DIR =0xffffffff;
  while(1)
  {
    count++;
    if(count==60)
    {
      count=1;
    }
    IO0CLR=Tab[count%10] | Tab[count/10]<<8;
    if(count==52 | count==54 | count==56 | count==58 | count<3) //定时提醒
    {
      IO0SET=0x80000000;
    }
    else 
    {
      IO0CLR=0x80000000;
    }
    delay();
    IO0SET=0x7fffffff;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?