flash.c

来自「keilc pic的版本 才搞到的 希望对大家有帮助」· C语言 代码 · 共 38 行

C
38
字号
/* FLASH.C - LED Flasher for the Keil MCB167-NET Board */

#include <reg167.h>
#include <stdio.h>
#include <intrins.h>

void wait (void)  {                        /* wait function */
  _nop_();                                 /* only to delay for LED flashes */
  _nop_();
  _nop_();
  _nop_();
  _nop_();
}

void main (void)  {
  unsigned int i;                          /* Delay var */
  unsigned int j;                          /* LED var */

  DP2  = 0x00FF;
  ODP2 = 0x0000;

  while (1) {                              /* Loop forever */
    for (j=0x0001; j != 0x0100; j<<=1){    /* Blink LED */
      P2 = ~j & 0x00FF;                    /* Output to LED Port */
      for (i = 0; i < 50000; i++)  {       /* Delay for 50000 Counts */
        wait ();                           /* call wait function */
      }
    }

    for (j=0x0080; j != 0; j>>=1){         /* Blink LED */
      P2 = ~j & 0x00FF;                    /* Output to LED Port */
      for (i = 0; i < 50000; i++)  {       /* Delay for 50000 Counts */
        wait ();                           /* call wait function */
      }
    }
  }
}

⌨️ 快捷键说明

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