技术热线: 4007-888-234

CCSC LED2.c程序功能和MCD2demo LED2.asm相似

更新时间: 2019-03-25
阅读量:645

CCSC LED2.c程序功能和MCD2demo LED2.asm相似
///////////////////////////////////////////////////////////////////////////////
// MPLAB IDE V7.11 + CCS C3.18
// LED2 for MCD2-demo
//
// by LW7807@163.com
// 2005/06/16
///////////////////////////////////////////////////////////////////////////////
#include "16F877A.h"                            // PIC16F877 header file
#use delay(clock=4000000)                       // for 4Mhz crystal
#fuses XT, NOWDT, NOPROTECT, NOLVP              // for debug mode

void main(void)
{
        int8 tmp = 0;                           // tmp var

        set_tris_b(0xff);                       // set PORTB for intput
        set_tris_c(0x00);                       // set PORTC for output
        output_c(tmp);                          // PORTC output 0

        while(1){
                while(1 == (input_b()&0x01))    // wait put button
                        {
                        delay_ms(10);
                        }

                output_c(++ tmp);               // output number

                while(0 == (input_b() & 0x01))  // wait free button
                        {
                        delay_ms(10);
                        }
                }//end while(1)
}//end main()