/***************************************************************************************
目的:通过 1 6 4 脚连接开关。产生8ms脉冲一次
。 1脚输出********************************
飞凌单片机该型号与PIC12C508相同,但是pic为8脚,8pb513B为6脚,其中,PIC2\7脚不用,
其他管脚通用。
日期:2015.4.28
修改:增加了100MS,50MS,10MS,5MS,1MS,200US,10US,6US,等几种延时的实测值,以备以后产生脉冲时
可以使用。该实测值为4M晶振4个指令周期,即一条指令1US的情况。
日期:2015.4.28
****************************************************************************************/
//#include<pic12f508.h>
#include<pic.h>
#define uchar unsigned char
#define uint unsigned int
//#define M1 GP1
//#define M2 GP2
//#define M3 GP3
//#define TTLIN GP4
#define TTLOUT GP1
__CONFIG(0x0a);
void initio()
{
//OSCCAL=0x00;
TRISGPIO=0b00000000;//
TTLOUT=0;
}
/***************************************************************************
***************************************************************************
****************************延时程序***************************************/
Delay100ms()//实测99.992MS
{ int x=3702;
while(x--)
asm("nop");
}
Delay50ms()//实测49.98MS
{ int x=1851;
while(x--)
asm("nop");
}
Delay10ms()//实测10.001MS
{ int x=369;
while(x--)
asm("nop");
}
Delay5ms()//实测5.006MS
{ int x=184;
while(x--)
asm("nop");
}
Delay1ms()//实测1.01MS
{ int x=36;
while(x--)
asm("nop");
}
Delay200us()//实测200us
{ int x=6;
while(x--)
asm("nop");
}
Delay100us()//实测100us
{ int x=2;
while(x--)
asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");
}
Delay10us()//10US,用于循环结束延时8M4.5US//实测10us
{
asm("nop");asm("nop");asm("nop");asm("nop");
}
Delay6us()//6US,用于循环结束延时8M4.5US//实测6uS
{
}
/***************************************************************************
******************************************************************************
****************************延时程序结束***************************************/
void main()
{ //GPPU=0;
// CMCON0=0XF7;
initio();
//uchar MOS;
//MOS=0;
TTLOUT=1;
Delay5ms();Delay1ms();Delay1ms();Delay1ms();
TTLOUT=0;
while(1);
}