⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 飞思卡尔的JL16程序
💻 C
字号:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */

#include "main_asm.h" /* interface to the assembly module */


void MCU_init(void); /* Device initialization function declaration */
#define uchar unsigned char
unsigned char P0,P2;
uchar const dis_7[12]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x40};//段码
uchar const bit_8[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//位码
uchar  dis[8]={0x00,0x00,11,0x00,0x00,11,0x00,0x00};//显示的初值
uchar  timedata[3]={0x00,0x00,0x00};//时分秒的数据—
uchar  ms50=0x00,con=0x00,con1=0x00,con2=0x00;//秒脉冲,时分秒电
void delayms(int t)
{
  int i,j;
  for(i=0;i<t;i++)   
  for(j=0;j<120;j++);
}
void scan(void)
{
  uchar k;
  dis[0]=(unsigned char )(timedata[0]%10);
  dis[1]=(unsigned char )timedata[0]/10;
  dis[3]=(unsigned char )(timedata[1]%10);
  dis[4]=(unsigned char )timedata[1]/10;
  dis[6]=(unsigned char )(timedata[2]%10);
  dis[7]=(unsigned char )timedata[2]/10;

  for (k=0;k<8;k++)
      {
           P0=dis_7[dis[k]];
           P2=bit_8[k];
           delayms(1);
           P2=0xff;
           }
        }
void main(void) {
  MCU_init(); /* call Device Initialization */

  /* include your code here */


  asm_main(); /* call the assembly function */


  for(;;) {
     __RESET_WATCHDOG();/* by default, COP is disabled with device init. When enabling, also reset the watchdog. */
      scan();

  } /* loop forever */
  /* please make sure that you never leave main */
}

/*作    者:   */
/* function: 显示时分秒电子表 P0送段码,P2送位码 */
 /*2007-2,                       */
 /*****************************************/


//sbit key0=P1^0;//进入调开关
//sbit key1=P1^1;//加开关
//sbit key2=P1^2;//减开关
//延时子程序

//键扫子程序
/* keyscan()
{
 EA=0;
if(key0==0)
    {
   delayms(10);
     while(key0==0);
         con++;TR0=0;ET0=0;
         if(con>=3)
         {
          con=0;TR0=1;ET0=1;}
        }
  if(con!=0)
   {
     if(key1==0)
         {
           delayms(10);
           while(key1==0);
           timedata[con]++;
           if(con==2)
con1=24;else con1=60;
if(timedata[con]>=con1)
 {timedata[con]=0;}
}
 }
if(con!=0)
 {
 if (key2==0)
{
 delayms(10);
while(key2==0);
timedata[con]--;
if(con==2)
con2=23;//
 else con2=59;
 if(timedata[con]<=0)
 {timedata[con]=con2;}
 }
 }
EA=1;
} */


⌨️ 快捷键说明

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