PDA

View Full Version : gấp.........vấn đề về nguồn cho 16f877a


dungcdt190502
15-09-2014, 10:44 PM
mọi người cho mình hỏi code sau mình mô phỏng chạy chuẩn mà sao khi nạp vào mạch no ko chạy ạ. chương trình có vấn đề j ko ạ.
#include <16F887.h>
#include <DEFS_16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#bit servo = porta.0
void servoRotate0() //0 Degree
{
unsigned int i;
for(i=0;i<50;i++)
{
servo = 1;
delay_us(800);
servo = 0;
delay_us(19200);
}
}

void servoRotate90() //90 Degree
{
unsigned int i;
for(i=0;i<50;i++)
{
servo = 1;
delay_us(1500);
servo = 0;
delay_us(18500);
}
}

void servoRotate180() //180 Degree
{
unsigned int i;
for(i=0;i<50;i++)
{
servo = 1;
delay_us(2200);
servo = 0;
delay_us(17800);
}
}

void main()
{
set_tris_a(0x00); //set các chân cua port c la chan xuat
porta = 0x00;
do
{
servoRotate0(); //0 Degree
delay_ms(2000);
servoRotate90(); //90 Degree
delay_ms(2000);
servoRotate180(); //180 Degree
}while(1);
}