View Single Post
Old 09-01-2014, 11:58 PM   #4
mroscar
Nhập môn đệ tử
 
Tham gia ngày: Sep 2012
Bài gửi: 2
:
anh em co the giup minh k??? minh viet tren mikro pro for dspic ma minh viet no k ngat! hic
unsigned int i,truoc,sau,trai,phai;
unsigned int struoc,ssau,strai,sphai;
void
void khaibaoPLL(){
// 7.3728MHz/2*32/2 7.3728*8= 58.9824/4 =14.7456 1/14.7456= 0.068
//1/58.9824=0.017
RCONbits.SWDTEN = 0; // disable watchdog timer
while(OSCCONbits.LOCK != 1) ; //wait PLL to lock
}
void khoitaotimer1 (){
T1CON.T1IE=1;
T1CON.T1IF=0;
TMR1=65533; //10us
T1CON=0x8000;//prescale 1:1
}
void Timer1Int () iv IVT_ADDR_T1INTERRUPT {
if(T1IF){
T1IF_bit=0;
TMR1=65533;
i++;
if(i>2000){
i=0;
LATD=0xff;
}
if(i>=truoc){RD0_bit=0;}
if(i>=sau){RD1_bit=0;}
if(i>=trai){RD2_bit=0;}
if(i>=phai){RD3_bit=0;}
}
}
void capnhat(){
struoc= truoc-truoc;
ssau= truoc-sau;
strai= truoc-trai;
sphai= truoc-phai;
}
void len(){
truoc=truoc++;
sau= truoc+ssau;
trai= truoc+strai;
phai= truoc+sphai;
}

void main () {
ADPCFG = 0xFFFF;

khoitaotimer1();
khaibaoPLL();
TRISD=0x00;
LATD=0xFF;
truoc = 100; sau=100;trai=100;phai=100;

//capnhat();
//len();

}
code minh viet anh xem dum sai cho nao chi e vs
mroscar vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn