miscellaneous.c

来自「基于7758的三相多功能电能表的设计程序」· C语言 代码 · 共 124 行

C
124
字号
#define MISCELL_GLOBLE    
#include "includes.h"    
/****************************************************************/   
/*description: delay a  while depend on the   PB_delay                                   */   
/*        each unit of delay is 260.1 ms   when applying 36014f                     */   
/*                                                                                                            */   
/*input parameters:  PB_delay:the delay number                                        */   
/*                                                                                                       */   
/*output argument: none                                                                          */   
/*relative globe variables: none                                                                */   
/***************************************************************/   
   
/*each unit of delay is 260.1 ms*/   
void delay(uchar PB_delay)   
{   
    uchar i,j,k;   
       
    for(i=PB_delay;i!=0;i--)   
        {   
        for(j=0;j<255;j++)   
            {   
            for(k=0;k<255;k++)   
                {   
                #ifdef crystal4M    
                nop();nop();   
                nop();nop();nop();   
                #else    
                    #ifdef crystal8M    
                    nop();nop();nop();nop();nop();   
                    nop();nop();nop();nop();nop();   
                    nop();nop();nop();   
                    #else    
                        #ifdef crystal10M    
                        nop();nop();nop();nop();nop();   
                        nop();nop();nop();nop();nop();   
                        nop();nop();nop();nop();nop();   
                        #else    
                        nop();nop();nop();nop();nop();   
                        nop();nop();nop();nop();nop();   
                        #endif    
                    #endif    
                #endif    
                }   
            }   
        }   
}   
   
void toggle_led0(void)   
{   
    P_LED0_INV;delay(2);P_LED0_INV;            
}   
   
void toggle_led1(void)   
{   
    P_LED1_INV;delay(2);P_LED1_INV;            
}   
/****************************************************************/          
/*description: delay a  while depend on the   PB_delay                                   */   
/*         each unit of sub_delay is 2.04 ms                                               */   
/*                                                                                                            */   
/*input parameters:  PB_delay:the delay number                                        */   
/*                                                                                                       */   
/*output argument: none                                                                          */   
/*relative globe variables: none                                                                */   
/***************************************************************/   
   
void sub_delay(uchar PB_delay)   
{   
    uchar i,j;   
    for(i=PB_delay;i!=0;i--)   
        {   
        for(j=0;j<255;j++)   
            {   
            #ifdef  crystal4M    
            nop();nop();nop();nop();nop();   
            nop();nop();nop();nop();nop();   
            nop();nop();nop();   
            #else    
                #ifdef  crystal8M    
                nop();nop();nop();nop();nop();   
                nop();nop();nop();nop();nop();   
                nop();nop();nop();nop();nop();   
                nop();nop();nop();nop();nop();   
                nop();nop();nop();nop();nop();   
                nop();nop();nop();nop();   
                #else    
                nop();nop();nop();nop();nop();   
                nop();nop();nop();nop();nop();   
                nop();nop();nop();nop();nop();   
                #endif    
            #endif    
            }   
        }   
}   
   
/****************************************************************/          
/*description: delay a  while depend on the   PB_delay                                   */   
/*         each unit of sub_delay is XX us                                               */   
/*                                                                                                            */   
/*input parameters:  PB_delay:the delay number                                        */   
/*                                                                                                       */   
/*output argument: none                                                                          */   
/*relative globe variables: none                                                                */   
/***************************************************************/   
   
void us_delay(uchar PB_delay)   
{   
    uchar i;   
    for(i=PB_delay;i!=0;i--)   
        {   
        nop();nop();   
        }   
}   
   
/****************************************************************/   
/*description:                                   */   
/*                            */   
/*                                                                                                            */   
/*input parameters:                                         */   
/*                                                                                                       */   
/*output argument:                                                                          */   
/*relative globe variables:                                                                */   
/***************************************************************/   

⌨️ 快捷键说明

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