#include "reg51.h"
#include <intrins.h>
#define uint8 unsigned char
#define uint16 unsigned short int
#define uint32 unsigned long
sbit SERVO0=P1^0; //¿ØÖƶæ»úμÄPWMêä3ö¿ú
//uint16 Servo0PwmDuty=1500; //PWMÂö3å¿í¶è
void InitTimer0(void)
{
TMOD |= 0x01; //éèÖö¨ê±Æ÷Ä£ê½
TL0 = 0xff; //éèÖö¨ê±3õÖμ
TH0 = 0x00; //éèÖö¨ê±3õÖμ
TF0 = 0; //Çå3yTF0±êÖ¾
TR0 = 1; //¶¨ê±Æ÷0¿aê¼¼Æê±
ET0 = 1; //¿a¶¨ê±Æ÷0ÖD¶Ï
}
void delay100us(unsigned int a) //@12.000MHz
{
unsigned char i, j;
_nop_;
_nop_;
i = 2;
j = 38;
do
{
while (--j);
} while (--i);
}
void main( )
{
InitTimer0(); //¶¨ê±Æ÷03õê¼»ˉ
EA = 1; //¿a×üÖD¶Ï
while(1)
{
SERVO0=1;
delay100us(500);
SERVO0=0;
delay100us(1000);
SERVO0=1;
delay100us(500);
}
}
我写的这个不行 求原程序 |