※ 引述《gecer (gecer)》之銘言:
: 我的石英是12MHz 預計讓pin 1 H 15000*1/12M=1.25mS L 15000*1/12M=1.25ms
拿上一篇的程式來改一改
#define tcycle ((65536-1500)+6)
#define __VTH (tcycle/256)
#define __VTL (tcycle%256)
void _T0ISR(void) interrupt 1 { //+2 Cycle 6 Cycle overhead
TR0=0; //+1 Cycle
TH0=__VTH; //+1 Cycle
TL0=__VTL; //+1 Cycle
TR0=1; //+1 Cycle
TF0=0;
P1=~P1;
}
void main(void){
PCON|=0x80;TMOD=0x21;TCON=0;TH0=__VTH;TL0=__VTL;IE=0x82;TCON=0x50;
do{
//
}while(1);
}