您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机PIC测试配置位的使用 正文
PIC测试配置位的使用

PIC测试配置位的使用

点击数:7833 次   录入时间:03-04 11:48:07   整理:http://www.55dianzi.com   PIC单片机

//K程序主要是测试配置位的使用要调用87X.H杳看
//定时中断
//原来4的程序是可能为没有按键放开的程序
//程序5修正按键松开的程序
//biao是指示是否有按键按下如果没有的话就指示为显示4个8
#include <pIC.h>
#include <pic1687x.h>
#define PORTDIT(add,bit) ((unsigned)(&add)*8+(bit))
#define PORTBIT(add,bit) ((unsigned)(&add)*8+(bit))
//__IDLOC(1233) ;
//__CONFIG (XT&PWRTEN) ;
static  bit  PORT_0 @  PORTDIT(PORTD,0);   /*定义PORTD 0位*/
static  bit  PORT_1 @  PORTDIT(PORTD,1);   /*定义PORTD 1位*/
static  bit  PORT_2 @  PORTDIT(PORTD,2);   /*定义PORTD 2位*/
static  bit  PORT_3 @  PORTDIT(PORTD,3);   /*定义PORTD 3位*/
static  bit  PORT_4 @  PORTDIT(PORTD,4);   /*定义PORTD 4位*/
static  bit  PORT_5 @  PORTDIT(PORTD,5);   /*定义PORTD 5位*/
static  bit  PORT_6 @  PORTDIT(PORTD,6);   /*定义PORTD 6位*/
static  bit  PORT_7 @  PORTDIT(PORTD,7);   /*定义PORTD 7位*/
//-------------------------------------------------
static  bit  PORTD_0 @  PORTBIT(PORTB,0);   /*定义PORTB 0位*/
static  bit  PORTD_1 @  PORTBIT(PORTB,1);   /*定义PORTB 1位*/
static  bit  PORTD_2 @  PORTBIT(PORTB,2);   /*定义PORTB 2位*/
static  bit  PORTD_3 @  PORTBIT(PORTB,3);   /*定义PORTB 3位*/
static  bit  PORTD_4 @  PORTBIT(PORTB,4);   /*定义PORTB 4位*/
static  bit  PORTD_5 @  PORTBIT(PORTB,5);   /*定义PORTB 5位*/
static  bit  PORTD_6 @  PORTBIT(PORTB,6);   /*定义PORTB 6位*/
static  bit  PORTD_7 @  PORTBIT(PORTB,7);   /*定义PORTB 7位*/
//const char table[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x7C};
unsigned char s;                    /*每0.125S累加1*/
unsigned char ss,fan;                  /*每1秒累加1*/
int i=0,tt;

unsigned char LEDadr,biao;
static unsigned char k,led1,led2,led2,led3,led4;
static unsigned char adrshow,count,show1,show2,show3,show4;//显示位控制
const char  table[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39}; //A~F
/*0,1,2,3,4,5,6,7,8,9,A,b,C,c,d,E,*/
void keysCAN();
void delay10ms(unsigned char time);
void Dispaly(unsigned char k);
unsigned char key,temp;
void tmint(void)
{   T0CS=0;
PSA=0;
PS2=0;
PS1=1;
PS0=1;
T0IF=0;
T0IE=1;
}
void interrupt clkint(void)   //定时器中断函数
{  if(T0IF=1)  //增加是定时中断时进入
  {
    TMR0=0x5b;
    T0IF=0;
    lEDAdr=ledadr+1;
    if(biao==0)

   { if (ledadr>count)
     {ledadr=0;}
      }
    if ((ledadr==1)&(show1==1||biao==1))
        {if(biao==1)
         {PORTC=0XFF;
          PORTA=0;
           RA0=1;}
         else {PORTC=led1;
         PORTA=0;
         RA0=1;}
          }
       if ((ledadr==2)&(show2==1||biao==1))
     {   PORTA=0;
          if(biao==1)
          {PORTC=0XFF;
            PORTA=0;
            RA1=1;}
          else {
          PORTA=0;
          PORTC=led2;
          RA1=1;}
             }
      if ((ledadr==3)&(show3==1||biao==1))
          {PORTA=0;
           if (biao==1)
          {PORTC=0xff;
           PORTA=0;
            RA2=1;}
           else {
           PORTA=0;
           PORTC=led3;
            RA2=1;}
                 }
     if ((ledadr==4)&(show4==1||biao==1))
           {PORTA=0;
            if (biao==1)
            {PORTC=0XFF;
            PORTA=0;
            RA3=1;
            ledadr=0;}
                else{
           PORTC=led4;
           PORTA=0;
            RA3=1;
            ledadr=0;}
              }
    if(s++>8){                 s=0;
         if(ss++>05)/*每分钟清0*/
             ss=0; 
              }
   /*  RC3=(bit)(s>4);//可改变占空比1秒闪一次
     RC1=(bit)(!ss);//1分闪一次
     RC2=(bit)(s==0 || s==2 || s== 4 || s== 6);//0.25秒闪一次*/
  }
}
main(void)
{  
    TRISD=0x0F;//低四位是输入,高四位为输出
    TRISC=0;
   // PORTD=0X55;
    TRISB=0x00;
    TRISC=0x00;
    PORTB=0X00;
    PORTC=0x00;
    RB0=1;RB2=0;//接两个LED,开始为全灭
    PCFG3=0;
    PCFG2=1;
    PCFG1=1;
    PCFG0=1;
    TRISA=0;
    PORTA=0;
    //RTC=0xff;
    T0CS=0;
    RA4=0;
    ledadr=0;
    tmint();              //调用定时器初始化程序   

[1] [2]  下一页


本文关键字:暂无联系方式PIC单片机单片机-工控设备 - PIC单片机

《PIC测试配置位的使用》相关文章>>>