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

📄 sled.lst

📁 使用Microchip公司16F648实现4*6键盘程序. 在PICC环境下编译通过,包含RS485通讯. 代码完整,可供参考.
💻 LST
字号:
     1: //led seriarl in merge out

     2: #include  "pic16f62xa.h"

     3: #include  "pic.h"

     4: #include  "typedefine.h"

     5: #include  "extern.h"

     6: 

     7: #define   LEDCLK    RA1 

     8: //#define    LEDCLK_1           RA0=1

     9: #define   LEDDATA       RA0 

    10: //#define    LEDDATA_1          RA1=1

    11: #define   LEDLACK       RA2 

    12: //#define   LEDLACK_1           RA2=1

    13: 

    14: bank1 unsigned int LedSLink;

    15: //bank1 volatile LEDCONTROL ledControl;   

    16: bank1 volatile LEDCONTROL ledControl;

    17: bank1 volatile static char aloneD[4];

    18:   

    19: const unsigned char LEDCode[] = 

    20: {

    21:         0x03,                   // 0

    22:         0x9f,               // 1

    23:         0x25,                   // 2

    24:         0x0d,                   // 3

    25:         0x99,                   // 4

    26:         0x49,                   // 5

    27:         0x41,                   // 6

    28:         0x1f,                   // 7

    29:         0x01,                   // 8

    30:         0x09,                   // 9

    31: };

    32: void CalculateSub(int Digit,char *p_aloneD);

    33: //void CalculateSub(int Digit,char *p_aloneD);

    34: 

    35: void LedDrive(void)

    36: {       

    37:         bank1 static char OffCnt;

    38:         bank1 static uint ShowDigit;

    39:     unsigned char SixCnt=16;

    40:     unsigned int TempLedData=0;

    41:         

    42:         if(ledControl.bits.once128ms)

    43:         {

    44:                 ledControl.bits.once128ms=0;    

    45:                 ShowDigit =   LedSLink;

    46:         CalculateSub(ShowDigit,aloneD);    //

    47:         }

    48: //

    49: //      if(Tag_ms == 1)

    50: //              Tag_ms= 0;

    51:         

    52: //      if(Tag_ms)

    53: //              Tag_ms = 0;

    54:         if(ledControl.bits.refurbish != 1)

    55:                 return;

    56:                 

    57:                 ledControl.bits.refurbish = 0;

    58: 

    59: 

    60:                 OffCnt++;

    61:                 switch (OffCnt)

    62:                 {

    63:                         case 1:

    64:                         {               

    65:                 //              TempLedData = aloneD[0];                                

    66:                 //              TempLedData = TempLedData<<8;                   

    67:                 //              TempLedData = TempLedData|0x10;                 //0xef;

    68:                         TempLedData  = LEDCode[aloneD[0]] ;   

    69:                         TempLedData |= 0x8000;                          

    70:                                 break;                      

    71:                         }                

    72: 

    73:                         case 2:

    74:                         {

    75: //                              TempLedData     = aloneD[1];                            

    76: //                              TempLedData = TempLedData<<8;                   

    77: //                              TempLedData = TempLedData|0x20;                 //0xdf;

    78:                         TempLedData  = LEDCode[aloneD[1]] ;   

    79:                         TempLedData |= 0x4000;   

    80:                                 break;                                                                  

    81:                         }

    82:                         case 3:

    83:                         {

    84: //                              TempLedData = aloneD[2];                                        

    85: //                              TempLedData = TempLedData<<8;                   

    86: //                              TempLedData = TempLedData|0x40;                 //0xbf;

    87:                         TempLedData  = LEDCode[aloneD[2]] ;   

    88:                         TempLedData |= 0x2000;   

    89:                                 break;                                                                  

    90:                         }

    91:                         case 4:

    92:                         {

    93:         //                      TempLedData = aloneD[3];                                        

    94:         //                      TempLedData = TempLedData<<8;                   

    95:         //                      TempLedData = TempLedData|0x80;                 //0x7f;

    96:                         TempLedData  = LEDCode[aloneD[3]] ;   

    97:                         TempLedData |= 0x1000;   

    98:                                 OffCnt=0;                                                               

    99:                                 break;                                                                  

   100:                         }

   101:                         default:

   102:                         {

   103:                                 OffCnt=0;

   104:                                 TempLedData=0;

   105:                                 break;                         

   106:                         }

   107:                 }

   108:         

   109:                 NOP();

   110:                 GIE = 0;

   111:          //     LEDLACK = 1;

   112:                 LEDLACK = 0; 

   113:                 SixCnt = 16; 

   114:                 do{

   115:                           if(TempLedData & 0x0001) //    

   116:                       {

   117:                                   LEDDATA=1;

   118:                           }

   119:                           else

   120:                           {

   121:                               LEDDATA=0;

   122:                           }

   123:                           LEDCLK = 1;

   124:                           TempLedData >>= 1;

   125:                           LEDCLK=0;

   126:               }while(--SixCnt); 

   127:              LEDLACK=1;   

   128:         //      LEDLACK = 0;

   129:                 NOP();     

   130:                 LEDCLK=0;    

   131:                 LEDDATA=0;   

   132:                 NOP();    

   133:                 NOP();      

   134:                 GIE = 1;

   135:                 return;       

   136: }//void LedDrive(void)

   137: 

   138: //10进制显示

   139: void CalculateSub(int Digit,char *p_aloneD)

   140: {

   141:         *p_aloneD = (char)(Digit/1000);

   142:         Digit -= *p_aloneD++ * 1000;

   143:         

   144:         *p_aloneD = (char)(Digit/100);

   145:         Digit -= *p_aloneD++ * 100;

   146:         

   147:         *p_aloneD = (char)(Digit/10);

   148:         Digit -= *p_aloneD++ * 10;

   149: 

   150:         *p_aloneD = (char)Digit;

   151:         p_aloneD = 0;

   152: }//void CalculateSub(int Digit,char *p_aloneD)

   153: 

   154:  

⌨️ 快捷键说明

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