light1.c

来自「一位十年经验美国工程师的工程代码」· C语言 代码 · 共 56 行

C
56
字号
//*************************************************************************
//                         LIGHT1.C
// flashes the lights on the demo board
//
//*************************************************************************
//#define PIC_CLK 8

#include <pic.h>

//unsigned char delayus_variable;

//#include "always.h"
#define XTAL_FREQ 8MHZ
#include "delay.h"
#include "delay.c"



void main(void)
{
	char count1,count2,temp;
	int  icount;
 PORTA=0x00;
 PORTB=0x00;
 TRISA=0x00;
 TRISB=0x01;     //-- all but RXD as output
 
 while(1)
 { 
  //-- Bit shift......
  for(count1=0;count1<100;count1++)
  {
   PORTB = 0x80;
   PORTA = 0xFF;
   for(count2=0;count2<8;count2++)
   { 
    DelayMs(30);
    PORTB=(PORTB>>1);
    PORTA=PORTA>>1;
   }
   DelayMs(100);
  }

  //-- Binary counter --
  temp=0;
  for(icount=0;icount<1024;icount++)
  {
	  PORTA=temp;
   PORTB=temp ^0xFF;
   temp++;
   DelayMs(50);
  }
 }
}

⌨️ 快捷键说明

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